[root@localhost ~]# systemctl start mysqld 啓動失敗mysql
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.sql
查看系統日誌報錯爲:socket
May 29 19:04:53 localhost mysqld: 2018-05-29T11:04:53.723812Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
May 29 19:04:53 localhost mysqld: 2018-05-29T11:04:53.723862Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
May 29 19:04:53 localhost mysqld: 2018-05-29T11:04:53.723871Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325440Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325475Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325483Z 0 [ERROR] Failed to initialize builtin plugins.
May 29 19:04:54 localhost mysqld: 2018-05-29T11:04:54.325485Z 0 [ERROR] Abortingui
報錯緣由大體爲:你的數據文件不可寫spa
致使緣由:yum安裝的mysql的擁有者是root,而mysql要求執行身份爲mysql,權限問題致使數據文件不可寫日誌
解決方法以下:code
[root@localhost ~]# chown -R mysql /var/lib/mysqlip
[root@localhost ~]# systemctl start mysqldstring
[root@localhost ~]# tailf /var/log/messages & it
日誌打印:
May 29 19:09:15 localhost mysqld: Version: '5.7.22' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
啓動成功
登陸 MySQL,此時不須要密碼,直接回車:
# mysql -u root -p
更改 root 密碼 爲 123456:
mysql> use mysql; mysql> update user set authentication_string=password("123456") where user='root'; mysql> flush privileges; # 刷新權限,不刷新的話可能致使mysql回車直接就會登陸
注意密碼字段名 5.7 版本的是 authentication_string,以前的爲 password。
修改完後,記得註釋掉 my.cnf 中的 skip-grant-tables 參數,重啓 MySQL 服務,就能夠用你設置的密碼登陸了。