在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
为我工作。希望对你有所帮助。
我在重新启动并删除所有*err文件后遇到了这个问题。
我发现/usr/local/etc文件夹中my.cnf.d目录不见了
它创造了它:
mkdir /usr/local/etc/my.cnf.d
我只是复制粘贴了位于/usr/local/etc中的my。cnf。default文件到这个目录。
然后MySQL可以重新启动:
cd /usr/local/var/mysql
mysql.server start
MySQL可以工作。
如果你的系统有多个版本的MySQL,那么你很可能会遇到这个PID错误:
我们可以从杀死所有MySQL进程开始:
sudo killall mysqld
转到/usr/local,选择你想要的MySQL版本,然后为它提供MySQL权限。在我的情况下,我需要版本8。
sudo chown -R mysql mysql-8.0.21-macos10.15-x86_64
打开/usr/local/mysql-8.0.21-macos10.15-x86_64文件夹,启动SQL server:
sudo。/ mysql。服务器启动(输入您的笔记本电脑密码)
如果它给出下面的输出…PID问题解决了
sudo ./mysql.server start
Starting MySQL
.. SUCCESS!
我希望这对你有用。
在检查错误日志后,我发现了这个:
120309 17:42:49 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120309 17:42:50 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
120309 17:42:50 [Warning] You need to use --log-bin to make --binlog-format work.
120309 17:42:50 [Note] Plugin 'FEDERATED' is disabled.
120309 17:42:50 InnoDB: The InnoDB memory heap is disabled
120309 17:42:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120309 17:42:50 InnoDB: Compressed tables use zlib 1.2.3
120309 17:42:50 InnoDB: Initializing buffer pool, size = 16.0M
120309 17:42:50 InnoDB: Completed initialization of buffer pool
120309 17:42:50 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /usr/local/mysql/data/ib_logfile0
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120309 17:42:50 mysqld_safe mysqld from pid file /usr/local/mysql/data/lu1s.local.pid ended
为了解决这个问题,我给了整个mysql文件夹的所有权:
cd /usr/local
sudo chown mysql mysql
sudo chown mysql mysql-5.5.21-osx10.6-x86_64
sudo chown _mysql mysql
sudo chown _mysql mysql-5.5.21-osx10.6-x86_64
然后(你也可以做命令行),我应用权限(一旦我把所有权给_mysql和mysql用户),从文件夹/usr/local/mysql-5.5.21-osx10.6-x86_64的“获取信息”菜单中的所有附带的文件夹。你不需要把它传给别名,因为它只是一个别名。
文件夹的名称取决于MySQL的安装版本。