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

ps auxf | grep mysql

如果你得到任何MySQL进程,使用kill -9 PID杀死该进程ID,然后尝试启动MySQL。

其他回答

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

我也有同样的问题。对我来说,它是在运行mysqld之前的安装时进行brew删除。Homebrew (brew)在卸载之前似乎不会停止服务。

在检查.err文件后,我看到了另一个MySQL副本可能正在运行的日志错误,在终止旧的服务后。然后我可以重新启动新的MySQL安装。

在/etc/ SELinux /config:

SELINUX=禁用并重新启动服务器。

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

不知何故,我搞砸了我在Mac OS X v10.11 (El Capitan)上的权限,决定从头开始重新安装MySQL。

我在El Capitan上使用Homebrew,并决定重新安装:

brew uninstall mysql
sudo rm -rf /usr/local/var/mysql
brew install mysql
mysql.server start # ... SUCCESS

新安装的文件权限从_mysql更改为包含我的用户名:

ls -alh /usr/local/var/mysql
drwxr-xr-x   22 lfender  admin   748B Mar 22 09:58 .
# ... etc.