在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

当前回答

我通过跑步解决了这个问题

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

这里myUserName是我当前的登录用户名。

其他回答

我在交换服务器IP地址后遇到了这个问题。在此之前,数据库工作正常。在/etc/my.cnf文件中有一个条目需要更新:

bind-address = xxx.xxx.xxx.xx

里面有旧的IP地址。

我试图重新安装MySQL,实际上我忘记停止服务器从我的旧安装。要解决这个问题,ps -ax | grep mysql并杀死[任何pid]。但话说回来,每个人都不一样。就像其他答案说的,转到/usr/local/var/mysql/并检查你的.err日志文件。

删除pid文件,然后再次启动mysqld。

简单的…

修复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/上的人那里得到了这个指南

当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