在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

当前回答

在我的情况下,我得到了这个问题在一个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时,可能会发生此错误。

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

我试着去掉所有的*。err文件,但我仍然得到相同的错误。我在错误日志中得到了一个错误:

InnoDB:试图打开先前打开的表空间。以前的表空间“erp/brand”在文件路径:./erp/brand.ibd下使用了“ID: 7”的空间。在“filepath: ./webdb1/system_ user.ibd”目录下,无法打开ID为7的表空间“webdb1/system_user”

所以我删除了所有的ib*文件,它工作:

rm -f *.err ib*

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

bind-address = xxx.xxx.xxx.xx

里面有旧的IP地址。

检查一下你的硬盘是否还有剩余空间。当我的硬盘没有剩余空间时,我就遇到了这个问题。

对我有效的解决方案是:不能在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/*