我最近在安装mysql 5.7.12,本来之前安装mysql 5.7.11时用命令
bin/mysqld --initialize --user=mysql
可以很好的初始化,但是用在5.7.12版本居然报错
[[email protected] mysql-5.7.12]# bin/mysqld --initialize --user=mysql
2016-04-28T09:50:25.142068Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-28T09:50:25.142323Z 0 [ERROR] Can‘t find error-message file ‘/usr/local/mysql/share/errmsg.sys‘. Check error-message file location and ‘lc-messages-dir‘ configuration directive.
2016-04-28T09:50:25.144865Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2016-04-28T09:50:25.144934Z 0 [ERROR] Aborting
后来发现centos自带的/etc/my.cnf和/etc/mysql没有删掉,后来删掉这两个文件之后在此使用这个命令
仍然报错
mysqld: Can‘t create directory ‘/usr/local/mysql/data/‘ (Errcode: 2 - No such file or directory)
2016-04-28T09:53:24.465575Z 0 [ERROR] Can‘t find error-message file ‘/usr/local/mysql/share/errmsg.sys‘. Check error-message file location and ‘lc-messages-dir‘ configuration directive.
2016-04-28T09:53:24.467928Z 0 [ERROR] Aborting
后来在网上一查发现使用mysqld命令时要初始化
应该在mysql祝文件夹下创建data文件,但是记得在5.7.11版本里面的data文件是自动生成的
mkdir data
然后执行下面一句
bin/mysqld --user=mysql --basedir=/usr/local/mysql-5.7.12 --datadir=/usr/local/mysql-5.7.12/data/ --initialize
2016-04-28T10:01:07.730549Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-28T10:01:08.194212Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-04-28T10:01:08.725913Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-04-28T10:01:08.810579Z 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: 213135a4-0d28-11e6-b869-000c299613e3.
2016-04-28T10:01:08.816207Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2016-04-28T10:01:08.819712Z 1 [Note] A temporary password is generated for [email protected]: %?kTFF<e8XXL
这算是成功了把,给出了初始密码,接下来把support-files/my-default.cnf复制到/etc/下,并配置一下
就可以了!