在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
在这里发布的一些答案的帮助下,我找到了这个问题
我先跑
sudo -我
所以我有根权限。
然后我删除了xxxx。犯错文件:
Rm -rf /usr/local/mysql/data/xxxx.err
当我在SafeMode中创建MySQL后,
/usr/local/mysql/bin/mysqld_safe开始
它将尝试启动并因为错误而退出…一个新的xxx。Err文件将被创建,你需要读取它来查看错误的原因:
Tail -f /usr/local/mysql/data/mysqld.local.err
在我的情况下,由于某种原因,它在/var/log/文件夹中缺少一些文件夹和文件…所以我创建了两个:
cd /var/log
mkdir mysql
触摸mysql-bin.index
创建新文件后,您需要更改权限:
chown -R _mysql /var/log/mysql
当所有这些步骤都采取后,我的数据库立即开始工作……
关键是要读取错误和日志,并找到错误的地方……
对我来说,解决方案是覆盖/纠正/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
为我工作。希望对你有所帮助。