看一下一共有多少个配置文件
root@ubuntu:/etc/mysql/conf.d# mysql --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
根据找到的目录查看文件:
root@ubuntu:/etc/mysql/conf.d# cat /etc/mysql/my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
root@ubuntu:/etc/mysql/conf.d# ls /etc/mysql/conf.d/
mysql.cnf mysqldump.cnf
root@ubuntu:/etc/mysql/conf.d# ls /etc/mysql/mysql.conf.d/
mysqld.cnf mysqld_safe_syslog.cnf
这两个地方又对应不同的配置文件。
上周修改的是
/etc/mysql/mysql.conf.d/mysqld.cnf
max_allow_packet=500M
然而重启后没有生效。
然而,在/etc/mysql/mysql.conf.d/mysqld.cnf 这个文件里也有这个参数,max_allow_packet=1M,修改它。
root@ubuntu:/etc/mysql/conf.d# cat /etc/mysql/conf.d/mysqldump.cnf
[mysqldump]
quick
quote-names
max_allowed_packet = 500M
重启数据库
- service mysql restart
不清楚为啥MySQL配置文件如此灵活