在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

当前回答

open /usr/local/var/mysql

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

brew install mysql

再次安装。

从这个解解出来的。

但是这个解决方案会删除数据库。

其他回答

open /usr/local/var/mysql

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

brew install mysql

再次安装。

从这个解解出来的。

但是这个解决方案会删除数据库。

尝试查找后缀为“.err”的日志文件。应该有更多的信息。它可能在:

/usr/local/var/mysql/your_computer_name.local.err

可能是权限有问题

检查是否有MySQL实例正在运行 Ps -ef | grep mysql 如果是,你应该停止它,或者终止进程: kill -9 PID 其中PID是显示在前一个命令输出的用户名旁边的数字 检查/usr/local/var/mysql/的所有权 ls -laF /usr/local/var/mysql/ 如果它是root的owner,你应该把它改为mysql或your_user sudo chown -R mysql /usr/local/var/mysql/

这是一个权限问题。它不能启动,因为它不能写入mac。err文件,因为它属于其他人。

确保/usr/local/var/mysql文件夹属于启动MySQL的用户。如果我以jack的方式启动MySQL,一切都很好。然而,如果你以根用户的身份启动它,它会创建一个mac.err文件(由根用户拥有),jack不能写入这个文件,所以当你试图以jack的身份重新启动它时,它会失败。

确保运行mysql的用户拥有该文件夹和文件。服务器启动 确保没有mac.err或mac.pid文件被其他人拥有。 启动是作为正确的用户。

对我来说,解决方案是覆盖/纠正/etc/my/cnf中的数据目录

我用自述文件中提供的说明从源代码构建MySQL 5.5.27:


# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions

# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data

# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &

# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

Mysqld_safe在没有解释的情况下自行终止。运行/etc/init.d/mysql.服务器启动导致错误:

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

I noticed something odd in the installation instructions though. It has ownership changed to mysql for the directory "data", but not to "var"; this is unusual because for years I have had to ensure that var directory was mysql writable. So I manually ran chown -R mysql /usr/local/mysql/var and then attempted to start it again. Still no luck. But worse, no .err file in the var dir - it was in the "data" dir! so scripts/mysql_install_db sets up camp in /usr/local/mysql/var, but the rest of the application seems to want to do its work in /usr/local/mysql/data!

所以我只是编辑了/etc/my.cnf,在部分[mysqld]下,我添加了一个指令,显式地将mysql的数据目录指向var(因为我通常期望它是任何方式),这样做之后,mysqld启动得很好。add指令看起来像这样:

数据= /usr/地方/mysql/var

为我工作。希望对你有所帮助。

在我的情况下,我得到了这个问题在一个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