在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

当前回答

对我来说,解决方案是覆盖/纠正/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

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

其他回答

错误日志说了什么?我得到了这个错误,它最终是my.cnf文件中的一个旧的无效设置,这是MySQL错误日志指示的。如果不是错误的配置设置,错误日志至少应该为您指明正确的方向。

这是5.5版本的一个问题:

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

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

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

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

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

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

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

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

似乎MySQL进程正在运行,因此您无法使用端口。用于查看正在运行的MySQL进程。

ps auxf | grep mysql

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