刚安装的mysql无法启动,提示没有权限
The innodb_system data file 'ibdata1' must be writable
[root@localhost ~]# mysqld --initialize
[root@localhost ~]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
一 无法启动mysql,可以查看mysql日志 默认路径
/var/log/mysql.log
2020-03-20T02:12:57.667801Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2020-03-20T02:12:57.668066Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2020-03-20T02:12:57.668410Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2020-03-20T02:12:57.668897Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2020-03-20T02:12:57.669159Z 0 [ERROR] [MY-010119] [Server] Aborting
mysql日志报错
根据日志查看提示,是innodb文件没有写入权限
查找ibdata1文件路径
[root@localhost ~]# find -name ibdata1
/var/lib/mysql/ibdata1
[root@localhost ~]# chmod -R 777 /var/lib/mysql
[root@localhost ~]# chown mysql:mysql -R /var/lib/mysql
三 接着启动服务
[root@localhost ~]# systemctl start mysqld.service
[root@localhost ~]# systemctl status mysqld.service
其他注意事项
另外注意一下mysql初始化的密码 也记录到 mysqld日志里面
[root@localhost ~]# cat /var/log/mysqld.log
2020-03-20T02:12:15.251589Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 335
2020-03-20T02:12:19.068387Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: fyIGo9o9(t.p
2020-03-20T02:12:57.636850Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 492
[root@host]# mysqladmin -u root password "new_password";
然后可以通过以下命令来连接到Mysql服务器:
[root@host]# mysql -u root -p Enter password:*******
出现问题的时候,要多查看日志。根据日志信息能锁定问题
链接:https://www.jianshu.com/p/12f4f66fc67f
来源:简书