XAMPP - MySQL 意外关闭

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18022809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:24:00  来源:igfitidea点击:

XAMPP - MySQL shutdown unexpectedly

mysqlxampp

提问by Austin

When I open XAMPP and click start MySQL button and it gives me an error. I had started it just before, but now it isn't working.

当我打开 XAMPP 并单击启动 MySQL 按钮时,它给了我一个错误。我之前已经开始了,但现在它不起作用。

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

12:19:12 PM [mysql] 正在尝试启动 MySQL 应用程序...
12:19:12 PM [mysql] 检测到状态更改:正在运行
12:19:13 PM [mysql] 检测到状态更改:已停止
12:19:13 PM [mysql] 错误:MySQL 意外关闭。
12:19:13 PM [mysql] 这可能是由于端口阻塞、缺少依赖项、
12:19:13 PM [mysql] 权限不当、崩溃或通过其他方法关闭
12:19:13 PM [mysql] ] 按日志按钮查看错误日志并检查
12:19:13 PM [mysql] Windows 事件查看器以获取更多线索
12:19:13 PM [mysql] 如果您需要更多帮助,请复制并发布
12:19: 13 PM [mysql] 论坛上的整个日志窗口

Here is the contents of the error log:

以下是错误日志的内容:

2013-08-02 12:19:12 4536 [Note] Plugin 'FEDERATED' is disabled.
2013-08-02 12:19:12 f64 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
2013-08-02 12:19:12 4536 [Note] InnoDB: The InnoDB memory heap is disabled
2013-08-02 12:19:12 4536 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2013-08-02 12:19:12 4536 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-08-02 12:19:12 4536 [Note] InnoDB: Not using CPU crc32 instructions
2013-08-02 12:19:12 4536 [Note] InnoDB: Initializing buffer pool, size = 16.0M
2013-08-02 12:19:12 4536 [Note] InnoDB: Completed initialization of buffer pool
2013-08-02 12:19:12 4536 [Note] InnoDB: Highest supported file format is Barracuda.
2013-08-02 12:19:12 4536 [Note] InnoDB: The log sequence numbers 0 and 0 in ibdata files do not match the log sequence number 1616798 in the ib_logfiles!
2013-08-02 12:19:12 4536 [Note] InnoDB: Database was not shutdown normally!
2013-08-02 12:19:12 4536 [Note] InnoDB: Starting crash recovery.
2013-08-02 12:19:12 4536 [Note] InnoDB: Reading tablespace information from the .ibd files...

2013-08-02 12:19:12 4536 [注意] 插件“联邦”被禁用。
2013-08-02 12:19:12 f64 InnoDB:警告:不推荐使用 innodb_additional_mem_pool_size。此选项可能会在未来版本中与选项 innodb_use_sys_malloc 和 InnoDB 的内部内存分配器一起删除。
2013年8月2日12时十九分12秒4536 [注]的InnoDB:InnoDB的存储器堆被禁用
2013年8月2日12时十九分12秒4536 [注]的InnoDB:互斥和rw_locks使用Windows互锁函数
2013年8月2日12:19:12 4536 [注] InnoDB:压缩表使用 zlib 1.2.3
2013-08-02 12:19:12 4536 [注] InnoDB:不使用 CPU crc32 指令
2013-08-02 12:19:12 453 [注意] InnoDB:初始化缓冲池,大小=16.0M
2013-08-02 12:19:12 4536 [注] InnoDB:缓冲池初始化完成
2013-08-02 12:19:12 4536 [注] InnoDB:支持的最高文件格式是梭子鱼。
2013-08-02 12:19:12 4536 [注意] InnoDB:ibdata 文件中的日志序列号 0 和 0 与 ib_logfiles 中的日志序列号 1616798 不匹配!
2013-08-02 12:19:12 4536 [注意] InnoDB:数据库没有正常关闭!
2013-08-02 12:19:12 4536 [注意] InnoDB:启动崩溃恢复。
2013-08-02 12:19:12 4536 [注意] InnoDB:从 .ibd 文件中读取表空间信息...

The most important error message is here:

最重要的错误信息在这里:

2013-08-02 12:19:12 4536 [ERROR] InnoDB:
Attempted to open a previously opened tablespace.
Previous tablespace mysql/innodb_table_statsuses space ID: 1 at filepath: .\mysql\innodb_table_stats.ibd.
Cannot open tablespace xat/paymentswhich uses space ID: 1 at filepath: .\xat\payments.ibd

2013-08-02 12:19:12 4536 [错误] InnoDB:
试图打开以前打开的表空间。
以前的表空间mysql/innodb_table_stats在文件路径中使用空间 ID:1:.\mysql\innodb_table_stats.ibd
无法在文件路径:.\xat\payments.ibd处打开使用空间 ID:1 的表空间xat/ payments

The rest of the log:

日志的其余部分:

InnoDB: Error: could not open single-table tablespace file .\xat\payments.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.

InnoDB:错误:无法打开单表表空间文件 .\xat\payments.ibd
InnoDB:我们不继续崩溃恢复,因为
如果我们不能将 InnoDB 日志中的日志记录应用到它,该表可能会变成InnoDB:损坏.
InnoDB: 解决问题并启动mysqld:
InnoDB: 1) 如果文件存在权限问题,mysqld 无法
打开文件 InnoDB: 打开文件,修改权限。
InnoDB:2)如果不需要该表,或者您可以从备份中恢复它,
InnoDB:那么您可以删除 .ibd 文件,InnoDB 将执行正常的
InnoDB:崩溃恢复并忽略该表。
InnoDB: 3) 如果文件系统或磁盘损坏,无法删除
InnoDB:.ibd文件,可以在my.cnf中设置innodb_force_recovery > 0
InnoDB:在这里强制InnoDB继续崩溃恢复。

What is the cause of these errors and how can I rectify them?

这些错误的原因是什么,我该如何纠正它们?

回答by Kratos

Hey I just did this and it worked:

嘿,我只是这样做了,它奏效了:

  1. exitXampp server
  2. go to your C:\xampp\mysql\datadirectory
  3. deletethe ibdata1file
  4. restartxampp server
  1. 退出Xampp 服务器
  2. 转到您的C:\xampp\mysql\data目录
  3. 删除ibdata1文件
  4. 重启xampp 服务器

It should work

它应该工作

回答by Kerim

  1. Go to mysql/data/
  2. Delete all random files (except the actual database folders)
  3. Restart Apacheand MySQL.
  1. 转到mysql/数据/
  2. 删除所有随机文件(实际数据库文件夹除外)
  3. 重新启动ApacheMySQL

It should fix it.

它应该修复它。

回答by matinict

My Xampp MySQL worked just follows as below:

我的 Xampp MySQL 工作如下:

01.Go to mysql/data/ directory
02. delete the ibdata1 & ib_logfile*(ib_logfile0,ib_logfile1,ib_logfile101) file
03. restart xampp server

回答by Ryan Williams

When you're notrunning XAMPP as an administrator, shutting down MySQL frequently causes corruption which means you have to repair or delete your tables. To avoid this you need to either run XAMPP as an administrator, or use the proper command prompt method for shutting down MySQL.

当您不是以管理员身份运行 XAMPP 时,关闭 MySQL 经常会导致损坏,这意味着您必须修复或删除您的表。为避免这种情况,您需要以管理员身份运行 XAMPP,或使用正确的命令提示方法关闭 MySQL。

You can delete ibdata1as Kratos suggests, but this can leave you with a broken database as other pieces of your database are still in the /mysql/data/folder. In my case, this residual data stopped me successfully installing WordPress.

您可以ibdata1按照 Kratos 的建议删除,但这可能会使您的数据库损坏,因为数据库的其他部分仍在/mysql/data/文件夹中。就我而言,这些残留数据阻止了我成功安装 WordPress。

A cleaner way of undoing the damage is to revert your whole /mysql/data/folder. Windows has built-in folder versioning — right click on /mysql/data/and select Restore previous versions. You can then delete the current contents of the folder and replace it with the older version's contents.

消除损坏的更简洁方法是还原整个/mysql/data/文件夹。Windows 具有内置文件夹版本控制 — 右键单击/mysql/data/并选择Restore previous versions. 然后,您可以删除文件夹的当前内容并将其替换为旧版本的内容。

Addendum: To ensure that you don't forget to run XAMPP as an administrator you can right click the XAMPP shortcut, go to Properties, then Advanced, and finally tick Run as administrator.

附录:为确保您不会忘记以管理员身份运行 XAMPP,您可以右键单击 XAMPP 快捷方式,转到Properties,然后Advanced,最后勾选Run as administrator

回答by aog

Add the following line below the [mysqld]section in the mysql config file (my.ini) and restart the apache web server and the mysql service afterwards.

[mysqld]在 mysql 配置文件 (my.ini)中的部分下方添加以下行,然后重新启动 apache Web 服务器和 mysql 服务。

[mysqld]
innodb_force_recovery = 4

回答by Eric Leschinski

I got the same kind of error in my C:\xampp\mysql\data\mysql_error.logwhen trying to start mysql.

C:\xampp\mysql\data\mysql_error.log在尝试启动 mysql 时遇到了同样的错误。

2013-08-05 01:20:32 6780 [ERROR] InnoDB: Attempted to open a previously 
  opened tablespace. Previous tablespace mysql/slave_relay_log_info uses 
  space ID: 3 at filepath: .\mysql\slave_relay_log_info.ibd. Cannot open  
  tablespace test_database/test_table which uses space ID: 3 at filepath:  
  .\test_database\test_table.ibd

You'll have to read the error closely. This says that test_databaseis preventing mysql from starting.

您必须仔细阅读错误。这表示test_database阻止 mysql 启动。

You could blow away the offending database, these steps fix the problem:

你可以吹走有问题的数据库,这些步骤可以解决问题:

  1. Make sure mysql and xampp is shut down completely.
  2. Go to your directory where mysql is installed, mine is: C:\xampp\mysql\data
  3. You should see a folder with the name of a database that you created. mine was test_database.
  4. Create a new folder somewhere else called C:\xampp\mysql\data\mysql\backuptablespace
  5. Drag and drop (don't delete) the offending database table folder to the backup directory.
  6. Try to start mysql again. For me it started right up in 1 second as expected.
  1. 确保 mysql 和 xampp 已完全关闭。
  2. 转到安装mysql的目录,我的是: C:\xampp\mysql\data
  3. 您应该会看到一个带有您创建的数据库名称的文件夹。我的是test_database
  4. 在其他地方创建一个名为的新文件夹 C:\xampp\mysql\data\mysql\backuptablespace
  5. 将有问题的数据库表文件夹拖放到(不要删除)备份目录。
  6. 尝试再次启动mysql。对我来说,它按预期在 1 秒内就开始了。

If it doesn't work, put the file back where you started and you'll be back where you started.

如果它不起作用,请将文件放回您开始的地方,您就会回到开始的地方。

If you don't want to delete the database and don't have backups:

如果您不想删除数据库并且没有备份:

If you don't have backups of table data and mysql won't start because something is corrupted you'll have to use the process of elimination to guess-and-check your way to exactly what you did that corrupted it. Follow these steps:

如果您没有表数据的备份并且 mysql 不会启动,因为某些内容已损坏,您将不得不使用消除过程来猜测并检查您所做的破坏它的确切方式。按着这些次序:

  1. Make a clone of the entire C:\xampp\and store it somewhere safe so you can get back to where you started.
  2. Use a "binary search" approach to try to locate the corrupted item in the mysql database. It could be a file, or a table, or a database, or a user or anything.
  3. Delete the entire database and see if that allows mysql to start. If it does, then put back the database and try removing some of the tables. If it doesn't, then try yanking out something else until it does start.
  4. Try removing these files from C:\xampp\mysql\data\mysql: db.frm db.MRD db.MYI db.opt user.frm user.MYD user.MYI

  5. When you get mysql to start, try putting things back until you find the one thing that you add which prevents it from starting. One bonus for this is you learn how mysql works under the hood.

  1. 制作整个副本C:\xampp\并将其存储在安全的地方,这样您就可以回到开始的地方。
  2. 使用“二进制搜索”方法尝试在 mysql 数据库中定位损坏的项目。它可以是文件、表、数据库、用户或任何东西。
  3. 删除整个数据库,看看是否允许 mysql 启动。如果是,则放回数据库并尝试删除一些表。如果没有,那么尝试拉出其他东西,直到它开始。
  4. 尝试从以下文件中删除这些文件C:\xampp\mysql\data\mysql: db.frm db.MRD db.MYI db.opt user.frm user.MYD user.MYI

  5. 当您启动 mysql 时,请尝试将内容放回原处,直到找到您添加的阻止它启动的内容。这样做的一个好处是您可以了解 mysql 是如何在幕后工作的。

Nuclear option:

核选项:

Something you did screwed up the mysql server. An uninstall and reinstall of XAMPP should undo the corruption.

你做的事情搞砸了mysql服务器。卸载并重新安装 XAMPP 应该可以消除损坏。

回答by Mathew Magante

If all answer above is not working, you can simply delete all file in data except the folder

如果以上所有答案都不起作用,您可以简单地删除数据中除文件夹之外的所有文件

Goto: C:\xampp\mysql\data

转到:C:\xampp\mysql\data

enter image description here

在此处输入图片说明

After that: Goto: C:\xampp\mysql\bin

之后:转到:C:\xampp\mysql\bin

then open with notepad my.ini, Its look like this.

然后用记事本my.ini打开 ,它看起来像这样。

enter image description here

在此处输入图片说明

Then delete or put into comment the port 3306 and change it to 8111 then run xamp with administrator and its work well.

然后删除或注释端口3306并将其更改为8111,然后以管理员身份运行xamp并且它工作正常。

回答by SITHU

I also faced this issue and this is how I solved.
1. Make sure xampp is not under sub-directory. For example, it should be C:\xampp
2. You might need to run as administrator in running the application.

我也遇到了这个问题,这就是我解决的方法。
1. 确保 xampp 不在子目录下。例如,它应该是 C:\xampp
2。您可能需要以管理员身份运行应用程序。

Hope this will work!

希望这会奏效!

回答by kyzen

Here is what I did. I restarted my computer. Next I run services.msc. I stopped the MySQL service then restarted it. The restarted the Xampp server.

这是我所做的。我重新启动了我的电脑。接下来我运行 services.msc。我停止了 MySQL 服务,然后重新启动了它。重新启动了 Xampp 服务器。

回答by Aammad Ullah

No solution above worked for me. then I did below:

以上没有解决方案对我有用。然后我在下面做了:

I deleted all the files inside C:\xampp\mysql\data\ directory except folders in this directory. It worked perfectly fine but my previous databases are not working now. So do above if you don't care it will delete all your previous databases in phpmyadmin.

我删除了 C:\xampp\mysql\data\ 目录中的所有文件,除了这个目录中的文件夹。它工作得很好,但我以前的数据库现在不起作用。所以如果你不关心它会删除你以前在phpmyadmin中的所有数据库。