[mysqld_safe] 中的参数使用mysqld_safe命令启动时不生效?

[mysqld_safe] 中的参数使用mysqld_safe命令启动时不生效?
今天遇到一个现象,把参数写在my.cnf的 [mysqld_safe]部分,但是参数却没有效果:
重现:
把max_connections=5写在 [mysqld_safe]中:
[root@10-10-96-190 etc]# cat /etc/my.cnf 
[mysqld]
datadir=/data
socket=/data/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
max_connections=5
log-error=/data/mysqld.log
pid-file=/data/mysqld.pid
使用mysqld_safe命令启动mysql
[root@10-10-96-190 mysql-advanced-5.6.22-linux-glibc2.5-x86_64]# ./bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 6102
[root@10-10-96-190 mysql-advanced-5.6.22-linux-glibc2.5-x86_64]# 150827 20:54:21 mysqld_safe Logging to '/data/mysqld.log'.
150827 20:54:21 mysqld_safe Starting mysqld daemon with databases from /data

[root@10-10-96-190 etc]# mysql -u root -S /data/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.22-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like '%max_connection%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+
1 row in set (0.00 sec)
查看文档可以知道,151是默认值:Default 151
这里看的话,对于 在mysqld_safe中设置的max_connections=5是没有效果的。
但是官方文档中写到:
mysqld_safe reads all options from the [mysqld], [server], and [mysqld_safe] sections in option
files.
是可以读到mysqld_safe部分的
是只对这个max_connections这个参数没有效果吗? 
经过尝试之后slave_skip_errors 之后,发现这个参数也是没有效果的。
但是对于log-error,pid-file 这两个参数看起来是有效果的。
证实一下,把这两个参数换个路径。
[root@10-10-96-190 etc]# cat /etc/my.cnf 
[mysqld]
datadir=/data
socket=/data/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
max_connections=5
log-error=/tmp/mysqld.log
pid-file=/tmp/mysqld.pid
改好之后,重新启动mysql
mysql> show variables like '%log_error%'
    -> ;
+---------------------+-----------------+
| Variable_name       | Value           |
+---------------------+-----------------+
| binlog_error_action | IGNORE_ERROR    |
| log_error           | /tmp/mysqld.log |
+---------------------+-----------------+
2 rows in set (0.00 sec)
确实是有效果的。
那么问题来了,对别的参数为什么没有效果。
通过对mysqld_safe的启动过程进行跟踪,发现了问题的所在。
解决方法:
在mysqld_safe的第234行加上
pick_args='1111'
然后再试一次:
[root@10-10-96-190 etc]# cat /etc/my.cnf 
[mysqld]
datadir=/data
socket=/data/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
max_connections=5
log-error=/tmp/mysqld.log
pid-file=/tmp/mysqld.pid
slave_skip_errors=all

[root@10-10-96-190 etc]# mysql -u root -S /data/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.22-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like '%max_connection%'
    -> ;
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 5     |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> show variables like '%skip%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| skip_external_locking  | ON    |
| skip_name_resolve      | OFF   |
| skip_networking        | OFF   |
| skip_show_database     | OFF   |
| slave_skip_errors      | ALL   |
| sql_slave_skip_counter | 0     |
+------------------------+-------+
6 rows in set (0.00 sec)

这样,他就使用到了[mysqld_safe]里的内容

转载请注明源出处
QQ 273002188  欢迎一起学习
QQ 群 236941212

请使用浏览器的分享功能分享到微信等