在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时,可能会发生此错误。

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

其他回答

这招对我很管用:

注意:这是一个硬重新安装。当所有其他选项都用尽时再使用。

在安装了Homebrew的Mac电脑上:

列出运行时存在的所有MySQL实例

brew services

通过运行删除每个实例

brew uninstall <instance_name>

删除/usr/local/var/mysql目录:

rm -rf /usr/local/var/mysql

使用Homebrew重新安装MySQL:

brew install mysql
brew install mysql@<version> #Optional

重新运行mysql。服务器启动:

mysql.server start

我也有同样的问题。移动/etc/my.cnf文件对我有用。我在这里得到了信息。

它可能与旧的MySQL进程有关。你得关掉它,重新启动。有时可能是由于MySQL配置文件中的冲突。尝试移动它并重新启动MySQL。

查看下面的URL了解更多详细信息。

http://linuxadministrator.pro/blog/?p=225

当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

在我的Homebrew MySQL安装中,我只需要将位于/usr/local/var/mysql/中的ib_logfile0和ib_logfile1移动到另一个目录。

然后我就用mysql了。服务器启动,一切正常。