MySQL: Starting MySQL….. ERROR! The server quit without updating PID file

本文提供了解决MySQL启动失败的具体步骤,包括重启计算机、删除配置文件和更新数据库文件等方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


今天启动MySQL 遇见了这个问题,网上搜索,结果各种改文件,删除文件纯属坑爹;在上边的网站上发现了问题的解决方案~老外总结的真不错!拿过来自己学习一下

This step-by-step guide is mainly for FreeBSD, however the idea is the same for Linux. Every once a while, when I update my FreeBSD box, the system likes to shutdown my MySQL server. Therefore, I need to start it again after the update is done. Unfortunately, the upgrade process is not smooth every time. Sometimes it will throw me some error.

1,启动MySQL
/usr/local/etc/rc.d/mysql.server start 
2,发现了下述错误
  
  Starting MySQL..... ERROR! The server quit without updating PID file.

3,错误信息很明确的定位你出现的问题
 Starting MySQL..... ERROR! The server quit without updating PID file (/var/db/mysql/www.icesquare.com.pid).
三种解决方案如下:

Solution 1: Reboot The Computer 重启你的电脑

 Although it sounds simple, but it really works. During the system upgrade, the OS may disable some of your daemons. Instead of troubleshooting each one by one, the easiest way is to start everything over. For example, I experienced this problem today after upgrading the Apache and Ruby (Yes, MySQL is not part of the update), and I got this error message afterward. After rebooting the computer, the error message is gone.
 这个是由于更新引起的,你重启电脑即可解决。

Solution 2: Remove Your MySQL Config File 删除你的配置文件

If you have modified your MySQL configuration file, MySQL may not like it few versions after (MySQL is not backward compatibility friendly). It can be the problem of using an unsupported variable, or something similar. The easiest way is to remove your configuration file, and try to start the MySQL server again:

Backup your MySQL configuration first.

mv /etc/my.cnf /etc/my.cnf.backup

And restart the MySQL server again:

/usr/local/share/mysql/mysql.server start

Hopefully you will see the following message:

Starting MySQL. SUCCESS!

Solution 3: Upgrade Your Database File 更新你的数据库文件

Sometimes, the newer MySQL doesn’t like the database created in earlier version. I discovered this when I upgrade to MySQL 5.5.7:

Starting MySQL..... ERROR! The server quit without updating PID file (/var/db/mysql/www.icesquare.com.pid).


Since MySQL tells me which PID file causes the problem, I open the file and take a look what’s going on:
sudo tail /var/db/mysql/www.icesquare.com.err

And I saw something interesting: tables: Table ‘mysql.proxies_priv’ doesn’t exist:
101112 10:49:16  InnoDB: Initializing buffer pool, size = 128.0M
101112 10:49:16  InnoDB: Completed initialization of buffer pool
101112 10:49:16  InnoDB: highest supported file format is Barracuda.
101112 10:49:17  InnoDB: 1.1.3 started; log sequence number 1589404
101112 10:49:17 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.proxies_priv' doesn't exist
101112 10:49:17 mysqld_safe mysqld from pid file /var/db/mysql/www.icesquare.com.pid ended

The reason is very simple. MySQL could not open a table created in the earlier version (< 5.7.7) because it is not compatible with the current version. So, we can try to start the MySQL in safe mode through rc.d. First, you can edit the /etc/rc.conf and put the following into the file:

mysql_enable="YES"
mysql_args="--skip-grant-tables --skip-networking"

Restart MySQL through rc.d:
If you did it right, you should see something like the following:
Starting MySQL.. SUCCESS!

Now, MySQL is already running the safe-mode. We want to perform a MySQL upgrade on all tables:

sudo mysql_upgrade

You should see something like this:

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock'
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock'
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.servers                                      OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Running 'mysql_fix_privilege_tables'...
OK

Now, we want to switch the MySQL back to normal mode by commenting the extra options in /etc/rc.conf:

mysql_enable="YES"
#mysql_args="--skip-grant-tables --skip-networking"

And restart MySQL through /etc/rc.d:

/usr/local/etc/rc.d/mysql-server restart

Now the MySQL is up and running again!

Happy MySQLing.

### 解决MySQL服务器启动时出现错误,未更新PID文件 当遇到 `ERROR! MySQL server PID file could not be found` 或者 `The server quit without updating PID file` 错误时,这通常意味着MySQL服务未能正常初始化并创建进程ID (PID) 文件。以下是几种可能的原因以及相应的解决方案。 #### 检查配置文件路径设置 确保my.cnf或my.ini中的datadir参数指向的是实际存在的目录,并且该位置有足够的写权限给运行mysqld的服务账户[^1]。 #### 清理残留的PID文件 有时旧有的、不再有效的`.pid`文件会阻止新的实例启动。应当手动移除位于指定的数据存储区域内的此类文件后再尝试重启服务[^2]。 #### 初始化数据目录 如果怀疑是由于数据损坏引起的问题,则可以在备份现有数据之后,在MySQL安装下的bin文件夹内通过命令提示符窗口输入如下指令来重新初始化数据目录: ```bash mysqld --initialize --console ``` 此操作将会生成一个新的root用户的临时密码,请妥善保管以便后续登录验证使用[^3]。 #### 数据库文件恢复或替换 对于因意外关闭或其他原因造成数据库内部结构受损的情况,可以考虑利用之前备份好的完好无损的一套表空间文件(如ibdata1, ib_logfile0等),将其复制到当前环境相应的位置上以实现快速修复。 #### 日志分析排查其他潜在问题 查看error log获取更多详细的报错信息有助于进一步诊断具体是什么阻碍了MySQL的成功启动。日志文件一般存放在与数据相同的文件夹里或者是按照自定义配置放置于其它地方。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值