When doing a mysql multi-instance installation before, the installation was successful, linux It can also be started successfully; however, moving support-files/mysqld_multi.server to the /etc/init.d/ directory and setting the startup (chkconfig xxx on) fails;
I found the problem and started to solve it. I found that service xxx start could not start multiple instances of mysql, but mysqld_multi start could be used; then after various attempts, I found that the mysql environment variables set by /etc/profile could be printed out in a normal environment, but The mysql environment variable cannot be printed in the service made by the shell;
My /etc/frofile file:
1 |
|
Execution: You can see that the mysql environment variable is set
1 2 |
|
Then we define a system V script
1 2 3 4 5 |
|
Give permissions and set it to service
1 2 |
|
Execute service: As a result, you can see that there is no mysql environment variable
1 2 |
|
1. Add export PATH=/usr/local/mysql/bin:$PATH
## to the service just set in /etc/init.d/xxx #Note:
When putting a shell script into the service, you need to set the PATH and other environments. Use of environment variable files in service filesTest preparationc Test programThe contents of LogTest.cpp are as follows:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
service file
LogTest.service file1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Environment variable file
Environment variable file LogTest is placed in /etc/sysconfig /Under contents.1 2 |
|
cp LogTest /usr/local/MyTest/2) Log configuration For log related configuration, please view https://blog. csdn.net/www_dong/article/details/128053496. 3) Service file loading
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 5 |
|
The above is the detailed content of How to solve the problem that Linux service cannot use system environment variables. For more information, please follow other related articles on the PHP Chinese website!