以which命令尋mysql于何處:
which mysql
得徑:
/usr/bin/mysql
以此徑尋配置文件:
/usr/bin/mysql --verbose --help | grep -A 1 'Default options'
顯示信息:
Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
其意為:
服务器先讀/etc/mysql/my.cnf,如不存在則讀/etc/my.cnf,仍不存在則讀~/.my.cnf文件
打開/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/
尋/etc/mysql/conf.d
無datadir,又尋/etc/mysql/mysql.conf.d
于其中 mysqld.cnf文件見datadir值更為"/mnt/mysql"