unknown variable 'defaults-file=/etc/my3316.cnf'
问题:
rm -rf /data/3316/* /usr/local/mysql57/bin/mysqld --initialize-insecure --defaults-file=/etc/my3316.cnf --user=mysql --basedir=/usr/local/mysql57 --datadir=/data/3316 &
[root@master ~]# rm -rf /data/3316/* [root@master ~]# /usr/local/mysql57/bin/mysqld --initialize-insecure --defaults-file=/etc/my3316.cnf --user=mysql --basedir=/usr/local/mysql57 --datadir=/data/3316 & [1] 2926 [root@master ~]# 2020-08-04T05:45:30.645456Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-08-04T05:45:32.049211Z 0 [Warning] InnoDB: New log files created, LSN=45790 2020-08-04T05:45:32.377653Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2020-08-04T05:45:32.397294Z 0 [ERROR] unknown variable 'defaults-file=/etc/my3316.cnf' 2020-08-04T05:45:32.397322Z 0 [ERROR] Aborting
分析:
使用指定的my3306.cnf,而不用默认的/etc/my.cnf文件,可以在启动时,在mysqld_safe后加上参数--default-file=/etc/my3306.cnf,但是要注意的是,主参数必须紧接着mysqld_safe后面,如果做第二个或者第二个以后的参数加入时,则会出现如下类似错误错误:
/usr/local/mysql57/bin/mysqld: unknown variable 'defaults-file=/usr/local/server/mysql2/etc/my.cnf' 且服务无法启动!
这是mysql的一个bug!
rm -rf /data/3316/* /usr/local/mysql57/bin/mysqld --defaults-file=/etc/my3316.cnf --initialize-insecure --user=mysql --basedir=/usr/local/mysql57 --datadir=/data/3316 &
[root@master ~]# rm -rf /data/3316/* [root@master ~]# /usr/local/mysql57/bin/mysqld --defaults-file=/etc/my3316.cnf --initialize-insecure --user=mysql --basedir=/usr/local/mysql57 --datadir=/data/3316 & [1] 2952 [root@master ~]# 2020-08-04T05:48:51.749894Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-08-04T05:48:53.562252Z 0 [Warning] InnoDB: New log files created, LSN=45790 2020-08-04T05:48:53.785986Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2020-08-04T05:48:53.859394Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2e0f311e-d616-11ea-992a-000c295d49ba. 2020-08-04T05:48:53.863827Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2020-08-04T05:48:55.026055Z 0 [Warning] CA certificate ca.pem is self signed. 2020-08-04T05:48:55.259603Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

浙公网安备 33010602011771号