请联系我 有广告合作意向的 请联系我

指定mysql或者mariadb的my.cnf文件加载位置

在对mysql和mariadb共存安装时,需要设置my.cnf文件位置,初始化时可用通过加载选项指定

./scripts/mysql_install_db –defaults-file=/etc/mysql/my.cnf –datadir=/data/mydb/ –basedir=/data/mariadb/ –user=mysql

然后support-files/mysql.server(/etc/init.d/mysqld)开关脚本里面也要设置下

$bindir/mysqld_safe –datadir=”$datadir” –pid-file=”$mysqld_pid_file_path” $other_args >/dev/null 2>&1 &

针对这行启动项,修改为

$bindir/mysqld_safe –defaults-file=/etc/mysql/my.cnf –datadir=”$datadir” –pid-file=”$mysqld_pid_file_path” $other_args >/dev/null 2>&1 &

查看mysql的my.cnf文件位置的方法:

[root@T_245 mariadb]# 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