Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
The following groups are read: mysqld server mysqld-5.7
我们使用mysqld去初始化数据库,也会默认去读以上列出的那些cnf文件,这就会造成莫名其妙的问题
通过下面可以看出像mysql这个数据库就没有创建,解决这个问题就是在初始化数据库的时候加上--no-defaults参数
[mysql@rws1270149 bin]$ ./mysqld --initialize --datadir=/scratch/mysql5.7/data2 --basedir=/scratch/mysql5.7
[mysql@rws1270149 bin]$ ls -al ../data2
total 10498080
drwxr-x--- 2 mysql mysql 4096 Jun 18 23:10 .
drwxr-xr-x 12 mysql mysql 4096 Jun 18 23:10 ..
-rw-r----- 1 mysql mysql 197 Jun 18 23:10 ib_buffer_pool
-rw-r----- 1 mysql mysql 2147483648 Jun 18 23:10 ib_logfile0
-rw-r----- 1 mysql mysql 2147483648 Jun 18 23:10 ib_logfile1
-rw-r----- 1 mysql mysql 2147483648 Jun 18 23:10 ib_logfile2
-rw-r----- 1 mysql mysql 2147483648 Jun 18 23:10 ib_logfile3
-rw-r----- 1 mysql mysql 2147483648 Jun 18 23:10 ib_logfile4
-rw-r----- 1 mysql mysql 12582912 Jun 18 23:10 ibdata1
[mysql@rws1270149 bin]$ ./mysqld --no-defaults --initialize --datadir=/scratch/mysql5.7/data3 --basedir=/scratch/mysql5.7
2019-06-19T06:21:21.279617Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-19T06:21:21.449518Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-06-19T06:21:21.526726Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-06-19T06:21:21.581174Z 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: 74ccf413-925a-11e9-ace7-0021f6312ac3.
2019-06-19T06:21:21.581992Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-06-19T06:21:21.582714Z 1 [Note] A temporary password is generated for root@localhost: qquLLpk9mF?V
[mysql@rws1270149 bin]$ ls -al ../data3
total 110628
drwxr-x--- 5 mysql mysql 4096 Jun 18 23:21 .
drwxr-xr-x 13 mysql mysql 4096 Jun 18 23:21 ..
-rw-r----- 1 mysql mysql 56 Jun 18 23:21 auto.cnf
-rw-r----- 1 mysql mysql 419 Jun 18 23:21 ib_buffer_pool
-rw-r----- 1 mysql mysql 50331648 Jun 18 23:21 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Jun 18 23:21 ib_logfile1
-rw-r----- 1 mysql mysql 12582912 Jun 18 23:21 ibdata1
drwxr-x--- 2 mysql mysql 4096 Jun 18 23:21 mysql
drwxr-x--- 2 mysql mysql 4096 Jun 18 23:21 performance_schema
drwxr-x--- 2 mysql mysql 12288 Jun 18 23:21 sys
<=======可以看到sys mysql performance_schema这几个数据库都创建了
参考了这个帖子