mysql报错无法启动解决方法

mysql报错无法启动解决方法

站点数据库连接失败.查看数据库运行状态,发现处于停止的状态。

[root@localhost ~]# systemctl status mysql
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since 二 2022-07-26 10:22:25 CST; 10min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1107 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)

726 10:22:16 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...
726 10:22:18 localhost.localdomain mysqld[1107]: Starting MySQL.Logging to '/www/server/mysql/data/localhost.localdomain.err'.
726 10:22:25 localhost.localdomain mysqld[1107]: ...... ERROR! The server quit without updating PID file (/www/server/mysql/data/localhost.localdomain.pid).
726 10:22:25 localhost.localdomain systemd[1]: mysqld.service: control process exited, code=exited status=1
726 10:22:25 localhost.localdomain systemd[1]: Failed to start LSB: start and stop MySQL.
726 10:22:25 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state.
726 10:22:25 localhost.localdomain systemd[1]: mysqld.service failed.

启动mysql.却返回如下报错

[root@localhost ~]# systemctl start mysql
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

定位日志,发现不存在MySQL的日志文件

[root@localhost ~]# tail /var/log/m
maillog            maillog-20220510   maillog-20220606   messages-20220426  messages-20220530  
maillog-20220426   maillog-20220530   messages           messages-20220510  messages-20220606  

查看MySQL的配置信息,发现配置为空!!!!! 但是在目录下发现了备份文件。

[root@localhost log]# cat /etc/my.cnf
[root@localhost log]# cat /etc/my.cnf.
my.cnf.bak  my.cnf.d/   

将备份文件覆盖原配置文件

 [root@localhost tmp]# cp /etc/my.cnf.bak /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y

重启MySQL 站点同样连接正常

[root@localhost tmp]# systemctl start mysql
[root@localhost tmp]# systemctl status mysql
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: active (running) since 二 2022-07-26 10:43:37 CST; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3991 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mysqld.service
           ├─3999 /bin/sh /www/server/mysql/bin/mysqld_safe --datadir=/www/server/data --pid-file=/www/server/data/localhost.localdomain.pid --sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_S...
           └─4617 /www/server/mysql/bin/mysqld --basedir=/www/server/mysql --datadir=/www/server/data --plugin-dir=/www/server/mysql/lib/plugin --user=mysql --sql-mode=NO_AUTO_CREATE_...

726 10:43:37 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...
726 10:43:37 localhost.localdomain mysqld[3991]: Starting MySQL SUCCESS!
726 10:43:37 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.

你可能感兴趣的:(常见问题及应对措施,mysql,数据库,java)