標籤:
我最近在安裝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/下,並配置一下
就可以了!
mysql 5.7.12----bin/mysqld --initialize --user=mysql出錯