在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
这招对我很管用:
注意:这是一个硬重新安装。当所有其他选项都用尽时再使用。
在安装了Homebrew的Mac电脑上:
列出运行时存在的所有MySQL实例
brew services
通过运行删除每个实例
brew uninstall <instance_name>
删除/usr/local/var/mysql目录:
rm -rf /usr/local/var/mysql
使用Homebrew重新安装MySQL:
brew install mysql
brew install mysql@<version> #Optional
重新运行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) |