mysql无法启动

mysql无法启动,提示"mysql.service: Failed with result 'exit-code'."

一、故障现象

[root@test mysql]# systemctl status mysql× mysql.service - MySQL Server     Loaded: loaded (/etc/systemd/system/mysql.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Wed 2024-02-21 15:02:11 CST; 2min 39s ago
   Duration: 1.911s
       Docs: man:mysqld(5.7)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 4743 ExecStart=/data/software/mysql/bin/mysqld --defaults-file=/etc/my.cnf (code=exited, status=1/FAILURE)
   Main PID: 4743 (code=exited, status=1/FAILURE)
        CPU: 236ms

2月 21 15:02:09 test systemd[1]: Started MySQL Server.
2月 21 15:02:11 test systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
2月 21 15:02:11 test systemd[1]: mysql.service: Failed with result 'exit-code'.




二、解决思路

#查看mysql错误日志,发现提示sock有问题
[root@test mysql]# tail -1000 /data/logs/mysql/mysql_error.log
2024-02-21T07:02:09.670307Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2024-02-21T07:02:09.670335Z 0 [Note] IPv6 is available.
2024-02-21T07:02:09.670339Z 0 [Note]   - '::' resolves to '::';
2024-02-21T07:02:09.670354Z 0 [Note] Server socket created on IP: '::'.
2024-02-21T07:02:09.674677Z 0 [ERROR] Can't start server : Bind on unix socket: Address already in use
2024-02-21T07:02:09.674688Z 0 [ERROR] Do you already have another mysqld server running on socket: /tmp/mysql.sock ?
2024-02-21T07:02:09.674695Z 0 [ERROR] Aborting

[root@test tmp]# ll
总用量 4
lrwxrwxrwx. 1 root  root  15  2月 20 16:13 mysql.sock -> /tmp/mysql.sock
-rw-------  1 mysql mysql  5  2月 21 15:02 mysql.sock.lock


[root@test tmp]# rm -f mysql.sock.lock 
[root@test tmp]# ll
总用量 0
drwx------ 3 root root 17  2月 21 14:55 systemd-private-b43bc79749134ae294082df3e3624049-chronyd.service-WR7gGc
drwx------ 3 root root 17  2月 21 14:55 systemd-private-b43bc79749134ae294082df3e3624049-dbus-broker.service-lGsNjr
drwx------ 3 root root 17  2月 21 14:55 systemd-private-b43bc79749134ae294082df3e3624049-kdump.service-rlbTVY
drwx------ 3 root root 17  2月 21 14:55 systemd-private-b43bc79749134ae294082df3e3624049-systemd-logind.service-4bOrlh
[root@test tmp]# systemctl start mysql
[root@test tmp]# systemctl status mysql
● mysql.service - MySQL Server
     Loaded: loaded (/etc/systemd/system/mysql.service; enabled; preset: disabled)
     Active: active (running) since Wed 2024-02-21 15:06:30 CST; 3s ago
       Docs: man:mysqld(5.7)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
   Main PID: 4906 (mysqld)
      Tasks: 27 (limit: 203192)
     Memory: 182.3M
        CPU: 219ms
     CGroup: /system.slice/mysql.service
             └─4906 /data/software/mysql/bin/mysqld --defaults-file=/etc/my.cnf

2月 21 15:06:30 test systemd[1]: Started MySQL Server.
[root@test tmp]# ll /tmp/
总用量 4
srwxrwxrwx 1 mysql mysql  0  2月 21 15:06 mysql.sock
-rw------- 1 mysql mysql  5  2月 21 15:06 mysql.sock.lock


img
在次此问题之前还遇到一个小问题

2月 21 14:53:20 test systemd[1]: Started MySQL Server.
2月 21 14:53:20 test systemd[815507]: mysql.service: Failed to locate executable /data/software/mysql/bin/mysqld: Permission denied
2月 21 14:53:20 test systemd[815507]: mysql.service: Failed at step EXEC spawning /data/software/mysql/bin/mysqld: Permission deni

image

posted @ 2024-02-21 16:18  wh459086748  阅读(1038)  评论(0)    收藏  举报