我使用的是 GoDaddy 的 Linux 服务器,并且没有任何已知原因,无法找到 PID 文件!这些是我得到的错误:
# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
# service mysqld status
mysqld: unrecognized service
# service mysql stop
ERROR! MySQL manager or server PID file could not be found!
# service mysql start
ERROR! Manager of pid-file quit without updating file.
# mysqladmin retart
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
答案1
这是你可以做的事情。由于该进程未运行并且未找到 pid 文件,因此您可以在 my.cnf 文件中指定它:
- 使用 Vim 或 Nano 等文本编辑器访问 /etc/my.cnf
- 添加以下内容:
pid-file = /var/run/mysqld/mysqld.pid
- 创建目录/文件:
mkdir /var/run/mysqld touch /var/run/mysqld/mysqld.pid chown -R mysql:mysql /var/run/mysqld
- 启动MySQL:
service mysql start
- 尾部日志文件以确保 MySQL 正确启动:
tail -f /path/to/mysql.log