在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

当前回答

这是macOS中MySQL数据库最简单的“PID”错误解决方案:

执行如下命令:

$ sudo mysql.server start
Starting MySQL
.. SUCCESS! 

使用此命令访问数据库:

$ mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.31 Homebrew

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
Database
information_schema
mysql
performance_schema
sys
4 rows in set (0.00 sec)

其他回答

我在Mac电脑上也遇到了同样的问题(正确地遵循了brew install建议的所有安装步骤)。

删除错误文件为我修复了它:

执行rm -rf /usr/local/var/mysql/dev.work。Err (dev.work是我的主机名)

这是因为dev.work.err属于_mysql:wheel,而不是我自己的用户名。 chon -ing错误文件可能也会修复它。

删除*。在错误提示的目录中找到的错误文件,创建MySQL所抱怨的文件,并重新启动MySQL。

我希望这对你有用。

在检查错误日志后,我发现了这个:

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的安装版本。

尝试删除ib_logfile0和ib_logfile1文件,然后再次运行MySQL:

rm /usr/local/var/mysql/ib_logfile0
rm /usr/local/var/mysql/ib_logfile1

这对我很管用。

在/etc/ SELinux /config:

SELINUX=禁用并重新启动服务器。