在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

当前回答

这个问题通常出现在你没有libaio的时候。安装了1个库。首先安装这个包,然后重做mysql_install_db步骤。

在终端上从解压库的文件夹中使用以下命令下载并安装库。

make prefix=$HOME install
cd /usr/local/lib
ln -sv $HOME/libaio.so.1 libaio.so.1

其他回答

在/etc/ SELinux /config:

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

这对我很管用……

检查所有正在运行的MySQL进程:

$ ps aux | grep mysql

USER     PID    %CPU  %MEM 
_mysql   5970   0.0   0.4 ...

然后使用以下命令杀死上面命令中列出的所有进程:

$ sudo kill -9 [PID]

将[PID]替换为上面列表中的单个PID,例如5970。

对使用第一个命令看到的所有行都这样做。

然后你可以再次启动你的MySQL服务器:

mysql.server start

这是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)

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

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

对我来说,解决办法很简单。

top

显示mysqld已经在运行。

sudo killall mysqld 

然后让这个过程开始。