重启后 XAMPP MySQL 服务崩溃

Posted

技术标签:

【中文标题】重启后 XAMPP MySQL 服务崩溃【英文标题】:XAMPP MySQL service crash after reboot 【发布时间】:2019-11-12 19:50:08 【问题描述】:

我刚刚安装了一个XAMPP 7.3.6-2-VC15 for Win64,安装后就没事了,mysql从控制面板启动没有错误,一切正常。

重新启动我的电脑后,Apache 仍在工作,但 MySQL 拒绝启动!我尝试重新安装 XAMPP,但它完全一样。 MySQL 工作正常,重启后停止工作。

这是我仅有的几条日志...

在控制面板中:

09:48:10  [mysql]   Attempting to start MySQL app...
09:48:10  [mysql]   Status change detected: running
09:48:11  [mysql]   Status change detected: stopped
09:48:11  [mysql]   Error: MySQL shutdown unexpectedly.
09:48:11  [mysql]   This may be due to a blocked port, missing dependencies, 
09:48:11  [mysql]   improper privileges, a crash, or a shutdown by another method.
09:48:11  [mysql]   Press the Logs button to view error logs and check
09:48:11  [mysql]   the Windows Event Viewer for more clues
09:48:11  [mysql]   If you need more help, copy and post this
09:48:11  [mysql]   entire log window on the forums

在日志文件中:

2019-07-02  9:48:10 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2019-07-02  9:48:10 0 [Note] InnoDB: Uses event mutexes
2019-07-02  9:48:10 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-07-02  9:48:10 0 [Note] InnoDB: Number of pools: 1
2019-07-02  9:48:10 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-07-02  9:48:10 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M
2019-07-02  9:48:10 0 [Note] InnoDB: Completed initialization of buffer pool
2019-07-02  9:48:10 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1834407
2019-07-02  9:48:10 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-07-02  9:48:10 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-07-02  9:48:10 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-07-02  9:48:10 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-07-02  9:48:10 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB.
2019-07-02  9:48:10 0 [Note] InnoDB: Waiting for purge to start
2019-07-02  9:48:10 0 [Note] InnoDB: 10.3.16 started; log sequence number 1834416; transaction id 265
2019-07-02  9:48:10 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2019-07-02  9:48:10 0 [Note] InnoDB: Buffer pool(s) load completed at 190702  9:48:10
2019-07-02  9:48:10 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-07-02  9:48:10 0 [Note] Server socket created on IP: '::'.

我尝试以下方法:

将端口更改为 3306 以外的端口 => 不成功 以管理员身份运行 xamp 控制面板 => 不成功 删除临时表 ibdata1 和 ibtmp1 => 不成功

如果有人有想法...

编辑:我尝试以管理员身份通过管理面板安装为 Windows 服务。所以,我在日志中有一些新行。似乎用户表已损坏...我该如何修复?

2019-07-02 10:04:41 0 [ERROR] mysqld.exe: Table '.\mysql\user' is marked as crashed and should be repaired
2019-07-02 10:04:41 0 [ERROR] mysqld.exe: Index for table '.\mysql\user' is corrupt; try to repair it
2019-07-02 10:04:41 0 [ERROR] Couldn't repair table: mysql.user
2019-07-02 10:04:41 0 [ERROR] Fatal error: Can't open and lock privilege tables: Index for table 'user' is corrupt; try to repair it

【问题讨论】:

小点 10.3.16可能意味着这是mariaDB而不是MySQL mariadb.com/kb/en/library/mysqlcheck 根据您的评论,我试试这个:C:\xampp\mysql\bin\mysqlcheck.exe: Got error: 2002: Can't connect to MySQL server on 'localhost' (10061) when trying连接。 您发现了一个错误。如果它再次发生this 将使您不必重新安装。 【参考方案1】:

这个对我有帮助:

从控制面板打开 shell 并使用以下命令启动 mysql:

mysqld –-console –-skip-grant-tables –-skip-external-locking

从控制面板打开另一个shell并使用以下命令修复数据库:

mysqlcheck -r --databases mysql --use-frm

停止mysql,关闭shell并正常重启mysql。

基于:Re: Corrupt mysql.users How to fix

【讨论】:

我终于从头开始重建,所以我无法尝试您的解决方案。不过这似乎是个好办法……【参考方案2】:

我和你一样遇到了这个问题。我已经解决了这个问题,如下所示。

Copy from xampp/mysql/backup folder and paste in xampp/mysql/data folder except ibdata1 file.

如果您从 xampp/mysql/data 替换 ibdata1 文件,那么某些数据库您将得到错误表不存在。

【讨论】:

只复制了“multi-master.info”,它起作用了,不知道为什么。

以上是关于重启后 XAMPP MySQL 服务崩溃的主要内容,如果未能解决你的问题,请参考以下文章

崩溃后如何让 XAMPP 中的 MySQL 服务器正常工作?

MySQL 在 Windows 中的 XAMPP 上不断崩溃

## 分布式事务面试官问我:MySQL中的XA事务崩溃了如何恢复??

MySQL不在xampp中使用端口?

将 mongodb.so 添加到 php.ini 后 XAMPP (Apache) 崩溃

崩溃后在新硬盘驱动器/Windows 上重用 xampp 文件夹