在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。

其他回答

这是5.5版本的一个问题:

下面是my.cnf文件[mysqld]部分的示例:

skip-character-set-client-handshake
collation_server=utf8_unicode_ci
character_set_server=utf8

参考:10.3.2服务器字符集和排序规则

对我有效的解决方案是:不能在MySQL服务器上创建PID文件,权限被拒绝

改变我的一些权限似乎奏效了。我使用的是一台2012年年中的MacBook Air,安装了Mac OS X v10.8.2 (Mountain Lion), MySQL安装了Homebrew。

chmod 0755 /var
chown root:wheel /var/tmp
sudo chmod 0771 /usr/local/var/mysql/*
open /usr/local/var/mysql

你只需要删除Finder中的文件夹,然后

brew install 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数据目录被意外地移动到错误的目录(/var/log,而不是/var/lib)。

在将数据移回/var/lib/mysql并重新启动服务器后,一切又恢复正常了。