当我尝试在 CentOS 6.5 机器上启动mysqld
守护程序时出现以下错误:
[root@hardin ~]# service mysqld start
Another MySQL daemon already running with the same unix socket.
Starting mysqld: [FAILED]
这很奇怪,因为服务没有启动(它配置为在默认端口上运行):
[root@hardin ~]# service mysqld status
mysqld is stopped
我不确定如何找到导致问题的 Unix 套接字:
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 10 [ ] DGRAM 12056 /dev/log
unix 2 [ ACC ] STREAM LISTENING 8720 @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 12878 /var/run/mcelog-client
unix 2 [ ] DGRAM 9289 @/org/kernel/udev/udevd
unix 2 [ ] DGRAM 12440 @/org/freedesktop/hal/udev_event
unix 2 [ ACC ] STREAM LISTENING 12275 /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 13128 /var/run/abrt/abrt.socket
unix 2 [ ACC ] STREAM LISTENING 12415 @/var/run/hald/dbus-jQMFHN9EAI
unix 2 [ ACC ] STREAM LISTENING 12408 @/var/run/hald/dbus-YQIZ9h7s4Q
unix 2 [ ACC ] STREAM LISTENING 12371 /var/run/acpid.socket
unix 2 [ ] DGRAM 14119
unix 3 [ ] STREAM CONNECTED 13579 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 13578
unix 2 [ ] DGRAM 13521
unix 3 [ ] STREAM CONNECTED 13493
unix 3 [ ] STREAM CONNECTED 13492
unix 2 [ ] DGRAM 13130
unix 2 [ ] DGRAM 13058
unix 2 [ ] DGRAM 13023
unix 2 [ ] DGRAM 12875
unix 2 [ ] DGRAM 12840
unix 3 [ ] STREAM CONNECTED 12773 /var/run/acpid.socket
unix 3 [ ] STREAM CONNECTED 12772
unix 3 [ ] STREAM CONNECTED 12767 @/var/run/hald/dbus-YQIZ9h7s4Q
unix 3 [ ] STREAM CONNECTED 12766
unix 3 [ ] STREAM CONNECTED 12716 @/var/run/hald/dbus-YQIZ9h7s4Q
unix 3 [ ] STREAM CONNECTED 12634
unix 3 [ ] STREAM CONNECTED 12714 @/var/run/hald/dbus-YQIZ9h7s4Q
unix 3 [ ] STREAM CONNECTED 12534
unix 3 [ ] STREAM CONNECTED 12435 @/var/run/hald/dbus-jQMFHN9EAI
unix 3 [ ] STREAM CONNECTED 12434
unix 3 [ ] STREAM CONNECTED 12410 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 12409
unix 2 [ ] DGRAM 12375
unix 3 [ ] STREAM CONNECTED 12295 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 12294
unix 3 [ ] STREAM CONNECTED 12289
unix 3 [ ] STREAM CONNECTED 12288
unix 3 [ ] DGRAM 9308
unix 3 [ ] DGRAM 9307
我将此机器用作 Git 服务器,运行 GitLab,它以前可以正常工作。冷启动后,它不再工作,因为unicorn
由于上述原因无法连接到 MySQL:
/home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) (Mysql2::Error)
我想知道如何解决这个问题并找出 MySQL 端口上正在运行的服务。
答案1
您可以使用
lsof -U | grep -i mysql
mysqld 28944 mysql 12u unix 0xffff88002cacb6c0 0t0 532368 /var/lib/mysql/mysql.sock
mysqld 28944 mysql 29u unix 0xffff88002a724380 0t0 532402 /var/lib/mysql/mysql.sock
查看哪个进程(如果有)拥有该套接字并采取适当的措施
如果您确定没有其他 MySQL 进程正在运行,您可以直接删除该/var/lib/mysql/mysql.sock
文件。当 MySQL 启动时,如果套接字不存在,它将重新创建它。