在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

当前回答

当MySQL被不正确地关闭后试图启动MySQL时,可能会发生此错误。

Take a look at the MySQL error log file. If it mentions something like "Check that you do not already have another mysqld process using the same data or log files.", then you need to properly shutdown that process. See what process MySQL is running on. Use the command lsof -i:3306 (the default port number for MySQL is 3306). Your output should look like this: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 4249 username 17u IPv4 0x7843d9d130469c0b 0t0 TCP localhost:mysql (LISTEN) Terminate the process running mysql: kill -15 4249 Kill -15 sends a signal to the process to free up any resources it is locking and terminate the process after. Now MySQL should start up with no problems: mysql.server start

其他回答

如果你的系统有多个版本的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!

我通过跑步解决了这个问题

sudo chown -R myUserName /usr/local/var/mysql

这里myUserName是我当前的登录用户名。

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

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

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

将日志文件“ib_logfile”移到“/var/lib/mysql”目录下,重启mysql。有时mysql会失败,因为它面临更新日志文件的困难

mv /var/lib/mysql/ib_logfile* /some/tmp/folder/

你也可以删除ib_logfile,因为它会在mysql重启后自动创建

现在重启mysql服务器

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