在Mac OS X v10.6 (Snow Leopard)上,启动MySQL会出现以下错误:

服务器退出,没有更新PID文件

文件my.cnf

[mysqld]
port            = 3306

socket          = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16K

pid-file=/var/run/mysqld/mysqld.pid

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

当前回答

当MySQL被不正确地关闭后试图启动MySQL时,可能会发生此错误。

Take a look at the MySQL error log file. If it mentions something like "Check that you do not already have another mysqld process using the same data or log files.", then you need to properly shutdown that process. See what process MySQL is running on. Use the command lsof -i:3306 (the default port number for MySQL is 3306). Your output should look like this: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 4249 username 17u IPv4 0x7843d9d130469c0b 0t0 TCP localhost:mysql (LISTEN) Terminate the process running mysql: kill -15 4249 Kill -15 sends a signal to the process to free up any resources it is locking and terminate the process after. Now MySQL should start up with no problems: mysql.server start

其他回答

这对我很管用……

检查所有正在运行的MySQL进程:

$ ps aux | grep mysql

USER     PID    %CPU  %MEM 
_mysql   5970   0.0   0.4 ...

然后使用以下命令杀死上面命令中列出的所有进程:

$ sudo kill -9 [PID]

将[PID]替换为上面列表中的单个PID,例如5970。

对使用第一个命令看到的所有行都这样做。

然后你可以再次启动你的MySQL服务器:

mysql.server start

简单的…

修复2002年MySQL套接字错误。

修复了即将出现的2002套接字错误-连接MySQL放置套接字的位置和OS X认为它应该在的位置。MySQL把它放在/tmp目录下,而OS X在/var/ MySQL目录下查找套接字是一种允许MySQL客户端/服务器通信的文件。

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

做得好:)这对我帮助很大!

我从http://coolestguidesontheplanet.com/上的人那里得到了这个指南

重新启动后,我遇到了同样的问题。以下是我的解决方法:

sudo chown -R _mysql /usr/local/var/mysql

在我的情况下,我得到了这个问题在一个VPS和cPanel。

我试了之前的大部分答案,但都没有成功。

check where your error log is. It would be mentioned at the end of the error line. ERROR! The server quit without updating PID file (/var/lib/mysql/111318.vps-11.com.pid). Open that file (/var/lib/mysql/111318.vps-11.com.err) and check the bottom for the latest lines. In my case, there is [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/db' is marked as crashed and should be repaired How solve this: Recovering and fixing the table indexes by command: [~]# myisamchk -r /var/lib/mysql/mysql/db.MYI MySQL is not running (Re)Start your MySQL server

删除*。在错误提示的目录中找到的错误文件,创建MySQL所抱怨的文件,并重新启动MySQL。