[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 服务,就能够用你设置的密码登陆了。