MySQL无法启动:MySQL意外关闭错误
在日志中我们看到类似的错误:
MySQL shutdown unexpectedly. This may be due to a blocked port, missing dependencies, improper privileges, a crash, or a shutdown by another method.
Press the Logs button to view error logs and check the Windows Event Viewer for more clues If you need more help, copy and post this entire log window on the forums
错误还可能包含以下文本:
Setting file 'C:\XAMPP\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait... File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB. mysqld.exe: Table '.\mysql\user' is marked as crashed and should be repaired. mysqld.exe: Index for table '.\mysql\user' is corrupt; try to repair it. Couldn't repair table: mysql.user. Fatal error: Can't open and lock privilege tables: Index for table 'user' is corrupt; try to repair it.
如何修复MySQL shutdown unexpectedly:
- 进入MySQL文件夹:例如在XAMPP中是/XAMPP/mysql。
- 将文件夹mysql/data重新命名为mysql/data_old。
- 在mysql文件夹中创建一个名为data的新文件夹。
- 将mysql/backup中的所有文件夹复制到mysql/data中。
- 将您创建的数据库的文件夹从mysql/data_old复制到mysql/data中。再次强调,仅指您自己创建的数据库命名的文件夹。
- 将文件ibdata1和所有包含ib_logfile的日志文件从mysql/data_old文件夹复制并粘贴到mysql/data文件夹中。
- 启动MySQL。
注意事项:
按步骤仔细执行,认真阅读每个步骤的描述。那么它应当会起作用。崩溃通常是由于存储用户设置的数据库(文件夹称为mysql/data/mysql,我们不复制)而发生。因此,您的数据库数据将被保留,但数据库的登录数据可能不会 - 您可能会有新的登录名root,密码为空。您可以在后续更改这些或添加新用户。最重要的是,我们的数据库完好无损!
祝好运,希望这个方法对你有帮助!
这个方法在我身上帮了我几次!然而,如果这个方法在您的情况下没有帮助,但您找到了一个有效的方法,请在下面的聊天中告诉我,我将更新文章。