1. 在手动启动mysql 的服务的时候发现有error ,
2. 然后通过status 查看mysql.service ,发现是“Failed to start MySQL 8.0 database server.”
[root@localhost mysql]# 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. [root@localhost mysql]# systemctl status mysqld.service ● mysqld.service - MySQL 8.0 database server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2021-01-28 12:14:04 CST; 15s ago Process: 7715 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS) Process: 7710 ExecStart=/usr/libexec/mysqld --basedir=/usr (code=exited, status=1/FAILURE) Process: 7672 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SU> Process: 7646 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS) Main PID: 7710 (code=exited, status=1/FAILURE) Status: "SERVER_BOOTING" Error: 2 (No such file or directory) Jan 28 12:14:04 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server... Jan 28 12:14:04 localhost.localdomain systemd[1]: mysqld.service: Main process exited, code=exited, sta> Jan 28 12:14:04 localhost.localdomain systemd[1]: mysqld.service: Failed with result ‘exit-code‘. Jan 28 12:14:04 localhost.localdomain systemd[1]: Failed to start MySQL 8.0 database server.
3.再通过mysql log 查看发现是“ibdata1” can‘t be writable
[root@localhost mysql]# cat /var/log/mysql.log cat: /var/log/mysql.log: No such file or directory [root@localhost mysql]# cat /var/log/mysql/mysqld.log 2021-01-28T04:13:38.121609Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.13) initializing of server in progress as process 7487 2021-01-28T04:13:49.083943Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Q)s9XxCC(btu 2021-01-28T04:13:55.959881Z 0 [System] [MY-013170] [Server] /usr/libexec/mysqld (mysqld 8.0.13) initializing of server has completed 2021-01-28T04:14:04.430539Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.13) starting as process 7710 2021-01-28T04:14:04.442393Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file ‘ibdata1‘ must be writable 2021-01-28T04:14:04.442414Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file ‘ibdata1‘ must be writable 2021-01-28T04:14:04.442427Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine 2021-01-28T04:14:04.442501Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2021-01-28T04:14:04.442521Z 0 [ERROR] [MY-010119] [Server] Aborting 2021-01-28T04:14:04.442767Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.13) Source distribution.
去到mysql 路径下check 该文件的权限
[root@localhost mysql]# ll /var/lib/mysql/ total 155700 drwxr-x--- 2 root root 6 Jan 28 12:13 ‘#innodb_temp‘ -rw-r----- 1 root root 56 Jan 28 12:13 auto.cnf -rw-r----- 1 mysql mysql 0 Jan 28 12:14 binlog.index -rw------- 1 root root 1680 Jan 28 12:13 ca-key.pem -rw-r--r-- 1 root root 1112 Jan 28 12:13 ca.pem -rw-r--r-- 1 root root 1112 Jan 28 12:13 client-cert.pem -rw------- 1 root root 1676 Jan 28 12:13 client-key.pem -rw-r----- 1 root root 5753 Jan 28 12:13 ib_buffer_pool -rw-r----- 1 root root 50331648 Jan 28 12:13 ib_logfile0 -rw-r----- 1 root root 50331648 Jan 28 12:13 ib_logfile1 -rw-r----- 1 root root 12582912 Jan 28 12:13 ibdata1 drwxr-x--- 2 root root 143 Jan 28 12:13 mysql -rw-r----- 1 root root 25165824 Jan 28 12:13 mysql.ibd drwxr-x--- 2 root root 4096 Jan 28 12:13 performance_schema -rw------- 1 root root 1676 Jan 28 12:13 private_key.pem -rw-r--r-- 1 root root 452 Jan 28 12:13 public_key.pem -rw-r--r-- 1 root root 1112 Jan 28 12:13 server-cert.pem -rw------- 1 root root 1676 Jan 28 12:13 server-key.pem drwxr-x--- 2 root root 28 Jan 28 12:13 sys -rw-r----- 1 root root 10485760 Jan 28 12:13 undo_001 -rw-r----- 1 root root 10485760 Jan 28 12:13 undo_002 [root@localhost mysql]#
chown mysql.mysql -R /var/lib/mysql
然后stop mysql.service ,最后再发start mysql.service 就可以了。