Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

How Can I Solve Error MySQL Shutdow

The document discusses the common error 'MySQL shutdown unexpectedly' encountered when starting MySQL in XAMPP, outlining potential causes such as blocked ports, missing dependencies, or file permission issues. It provides various troubleshooting methods, including deleting specific files in the MySQL data directory and restoring from backups, while cautioning against actions that could lead to data loss. The question has been closed on the forum due to its non-programming nature, despite receiving numerous views and comments over the years.

Uploaded by

jibep93404
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

How Can I Solve Error MySQL Shutdow

The document discusses the common error 'MySQL shutdown unexpectedly' encountered when starting MySQL in XAMPP, outlining potential causes such as blocked ports, missing dependencies, or file permission issues. It provides various troubleshooting methods, including deleting specific files in the MySQL data directory and restoring from backups, while cautioning against actions that could lead to data loss. The question has been closed on the forum due to its non-programming nature, despite receiving numerous views and comments over the years.

Uploaded by

jibep93404
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

How can I solve "Error: MySQL shutdown unexpectedly"?

[closed]
Asked 11 years, 7 months ago
Modified 4 months ago
Viewed 2.7m times
575

Closed. This question is not about programming or software development. It is not currently accepting
answers.
This question does not appear to be about a specific programming problem, a software algorithm, or
software tools primarily used by programmers. If you believe the question would be on-topic on another
Stack Exchange site, you can leave a comment to explain where the question may be able to be
answered.

Closed 11 months ago.

The community reviewed whether to reopen this question 11 months ago and left it closed:

Original close reason(s) were not resolved

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

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

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...

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_stats uses space ID: 1 at filepath:
.\mysql\innodb_table_stats.ibd. Cannot open tablespace xat/payments which uses space ID: 1 at filepath:
.\xat\payments.ibd

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.

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

mysqlapachexampp
Share
Improve this question
Follow
edited Sep 29, 2024 at 6:49
Mahdi Bashirpour’s user avatar
Mahdi Bashirpour
18.8k1717 gold badges131131 silver badges151151 bronze badges
asked Aug 2, 2013 at 17:27
Austin’s user avatar
Austin
5,78733 gold badges1414 silver badges1111 bronze badges
I just deleted info files in my xampp\mysql\data\ folder and it works for me. –
Asim Sajjad
CommentedJul 7, 2023 at 7:16
3
What is the gist of this? A TCP/IP port number conflict with some other software is causing it, and the
solution is to change to another port number? Why doesn’t any of the answers state this? Why does it
need 100 answers? –
Peter Mortensen
CommentedNov 12, 2023 at 1:57
2
@PeterMortensen And how is (now "was") it still open after all these years? The fact that XAMPP is a
"programming tool" doesn’t make every basic MySQL Server issue on-topic :-/ –
NotTheDr01ds
CommentedMar 28, 2024 at 6:18
Maybe the port 3306 is used; you try to execute this command on "command promp" or PowerShel : npx
kill-port 3306 . and try to run XAMP, that work for me –
Mounir bkr
CommentedNov 20, 2024 at 11:08
Add a comment
89 Answers
Sorted by:
Highest score (default)
1
2
3
Next
2160

+50
Important: do not delete the ibdata1 file. You could destroy all your databases.

Instead, first try using the MySQL backup folder which is included with XAMPP. So do next steps:

Rename folder mysql/data to mysql/data_old


Make a copy of mysql/backup folder and name it as mysql/data
Copy all your database folders from mysql/data_old into mysql/data (except mysql, performance_schema,
and phpmyadmin folders)
Copy mysql/data_old/ibdata1 file into mysql/data folder
Start MySQL from XAMPP control panel
And, voilà!

As mentioned by some users, this is an emergency solution, not a permanent one. After recovering your
data is strongly recommended to back it up, and reinstalling XAMPP, because the failure is related to a
malfunction from some of the files of XAMPP, not the databases.

Share
Improve this answer
Follow
edited Oct 26, 2023 at 14:31
Peter Mortensen's user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered May 17, 2020 at 22:20
Fabrizio Valencia's user avatar
Fabrizio Valencia
22.2k44 gold badges1818 silver badges1919 bronze badges
8
I also had to copy back the files ib_logfile0 and ib_logfile1 to prevent this kind of errors showing up in the
log: [ERROR] InnoDB: Page [page id: space=1, page number=3] log sequence number 10638137774 is
in the future! Current system log sequence number 1792801. [ERROR] InnoDB: Your database may be
corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to
mariadb.com/kb/en/library/innodb-recovery-modes for information about forcing recovery. This
stackoverflow.com/a/20617180/867327 refers to innodb_force_recovery –
patrox
CommentedJul 9, 2020 at 7:42
75
I've resorted to this answer sooo many times that I even wrote a PowerShell script to automate the
process: gist.github.com/josemmo/24e35f2b4984a4370ce2c164f5956437 –
josemmo
CommentedAug 28, 2020 at 18:50
4
As per @josemmo gist, it's important to note to exclude mysql, performance_schema, phpmyadmin when
copying directories to mysql/data –
claw68
CommentedSep 13, 2020 at 5:08
2
It did work, but I deleted ibdata1 file based on incorrect advice above. Now I lost all of my tables. I've got
only table names with no content inside. Is there any way to recover the ibdata1 that I deleted? –
Brian
CommentedSep 13, 2020 at 17:46
7
No use, still keep repeating the same issue after few days. –
Thirsty Six
CommentedApr 29, 2022 at 5:39
Show 41 more comments
255

Important: Deleting this file may render any existing MySQL data unusable. Use with caution

I just did this and it worked:

exit Xampp server


go to your C:\xampp\mysql\data directory
delete the ibdata1 file
restart xampp server
It should work.

Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:08
Peter Mortensen's user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Aug 10, 2013 at 13:14
Kratos's user avatar
Kratos
3,06311 gold badge1313 silver badges22 bronze badges
54
This works and should likely be marked as the correct answer. However rename the file to ibdata1.bak
rather than delete it. Just to be save. –
Lorenz Lo Sauer
CommentedSep 3, 2013 at 12:13
26
This will, of course, destroy all the data which was stored in that file (all the InnoDB tables which were
created before setting innodb_file_per_table to enabled). The methods suggested in the log message
seem suprtior to me. –
Tgr
CommentedOct 12, 2013 at 10:50
18
I also had to delete ib_logfile0 and ib_logfile1 to get it to work –
Allan Macmillan
CommentedJun 19, 2014 at 18:58
16
Ouch! Blowing away ibdata1 is equivalent to losing all your data (or at least all that are ENGINE=Innodb !

Rick James
CommentedMar 14, 2017 at 4:16
36
The most upvoted unexplained reckless thing you can do –
user10089632
CommentedJan 14, 2018 at 10:36
Show 15 more comments
155

Aug 2023
Disclaimer
Although many people said 'it worked' and very few say 'it didn't'.

It is hard to say what could be the cause and it is not working. Personally, the solution provided below
worked for me and I didn't get any issues so far hence I am sharing this.

I don't suggest uninstalling, so you can basically back up the file and try this solution. If it doesn't work
then place those files again.

Worked on other versions


This issue works on other XAMPP versions too. I have not tested personally, but some users have. (If you
have tested on a different version, let me know in the comment, I will add it here)

XAMPP v8.1.6 - Saeid Z


XAMPP v7.4.16 - CapelliC
XAMPP v3.3.0 - Myself
Feb 2022 (Problem)
I had the same problem today (2 Feb 2022). I fixed this using the same solution I mentioned below (See
Dec 2021 (Solution))

XAMPP Issue Screenshot


Enter image description here

XAMPP Fixed
Enter image description here

Dec 2021 (Solution)


Since this question is active continuously, I will try my best to solve it.

My issue
I visit this post every time this issue happens. The only thing I tried was that I uninstalled XAMPP and
reinstalled it, which fixed the problem. That was on my old system.

I am using Windows 10 brand new without any unwanted software or issues, and I got this unexpected
shutdown again after a long time. I came to this question, hoping someone would tell me actually what
was going on instead of fixing these issues. But unfortunately, I could not find it.

Just to clarify, my new issue is not with

port
unexpected shutdown
windows stuck
unwanted software
virus or malware.
One day I turned on XAMPP, and it stops working.

Method 1 (22 Dec 2021)


Stop MySQL.
Go to the C:/xampp/mysql directory and copy the data folder and keep it somewhere else (probably in
another drive) as a backup.
Go to your original data folder (C:/xampp/mysql) and sort the files by 'Type.'
Select the files that have the type INFO File and delete them (screenshot below).
Start MySQL. It should work now.
Method 1 Screenshot
Enter image description here

Important
Not necessarily the solution above will always fix the issue. Sometimes it will not. To avoid the major risk
of losing the data, try these.

Turn on MySQL in the Control Panel ONLY IF NEEDED.


DO NOT set the XAMPP Control Panel to turn it on windows startup.
Back up DB whenever possible. If not try to back up every weekend.
Wait until Apache loads completely. When you turn on Apache it takes a few sec to load (indicated by the
hour glass). Once it is loaded you turn on MySQL. - updated on Aug 2023
PS: I will try to update this answer whenever the above method(s) don't work. I will try to explain it in the
simplest way possible without uninstalling XAMPP.

Share
Improve this answer
Follow
edited Oct 26, 2023 at 14:40
Peter Mortensen's user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Dec 22, 2021 at 5:56
Dexter's user avatar
Dexter
9,34444 gold badges4646 silver badges4646 bronze badges
4
Still the same error occur –
Merbin Joe
CommentedMar 18, 2022 at 4:43
1
Worked for me, running xampp 7.4.16 –
CapelliC
CommentedMar 20, 2022 at 17:48
1
@Mustafasabir I still have all the data after doing this. –
Dexter
CommentedJun 22, 2022 at 10:33
3
Thanks, worked for me in xammp v8.1.6 . Please summarize it a little :) –
Saeid Z
CommentedJul 12, 2022 at 15:55
3
Worked for me in xampp v3.3.0. Thank you so much –
Albert Ruelan
CommentedJul 19, 2022 at 9:44
Show 18 more comments
96

If the previous answers are not working, you can try deleting all the files in data, except for the folder

Go to the directory: C:\xampp\mysql\data and delete the following files:


An image showing the directory C:\xampp\mysql\data in Windows Explorer. The files (but not the folders)
are selected, the image indicates these should be deleted. The files are aria_log.00000001,
aria_log_control, ib_logfile0, ib_logfile1, ibdata1, multi-master.info, mysql.pid, and mysql_error.

After that, go to the directory C:\xampp\mysql\bin and open my.ini in a text editor. It will look like this:

An image showing the contents of my.ini. The line(s) containing port information are highlighted in the
image.

Then delete comment out the port 3306 and change it to 8111. Then, run xampp with administrator
privileges and it will work.

Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:40
Peter Mortensen's user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Jan 28, 2020 at 2:36
Mathew Magante's user avatar
Mathew Magante
1,40755 gold badges2121 silver badges2828 bronze badges
Add a comment
84

Working solution: Follow the below listed steps


Step 1. Rename the folder C:\xampp\mysql\data to C:\xampp\mysql\data_bkp (you can use any name).

Step 2. Create a new folder, C:\xampp\mysql\data.

Step 3. Copy the content that resides in mysql\backup to the new mysql\data folder.

Step 4. Copy all your database folders that are in mysql\data_bkp to mysql\data (skipping the mysql,
performance_schema, and phpmyadmin folders from mysql\data_bkp).

Important note: Please do not replace the existing files while pasting (click skip for these files)

Enter image description here

Step 5. Finally copy the ibdata1 file from mysql\data_bkp and replace it inside the mysql\data folder.

Step 6. Start MySQL from XAMPP control panel.

And, it's done. No databases were lost, no ports changed, no run as administrator, no force recovery, no
kill mysqld process, no restoring from previous versions, and no more errors.

Share
Improve this answer
Follow
edited Dec 4, 2023 at 19:52
Peter Mortensen's user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered May 28, 2021 at 6:47
Rohit Saini's user avatar
Rohit Saini
1,00799 silver badges1313 bronze badges
1
Although this step works but makes sure you test it out. If you have an existing database table, it will all
break. If you have a new installation of XAMPP then this might help you. –
Dexter
CommentedSep 8, 2021 at 1:55
1
It works for me. No database lost. One of the best answer. –
Albert George
CommentedNov 9, 2022 at 7:07
1
Only this post has solved my Mysql problem. Best one here. Thanks so much, man. –
mowx
CommentedJan 5, 2023 at 12:47
2
Your welcome @mowx . We rise by lifting other. –
Rohit Saini
CommentedJan 5, 2023 at 15:01
3
This post solves my case. But it deleted all my BDs user accounts, so keep in mind we have to create
them again (with their privileges). –
quinqui
CommentedNov 24, 2023 at 14:24
Show 6 more comments
52

Simple solution: Open the shell from the XAMPP Control Panel:

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


Then again open another shell and run

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


Now close both shells and restart the XAMPP.

Share
Improve this answer
Follow
edited Nov 12, 2023 at 1:52
Peter Mortensen's user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Sep 16, 2022 at 5:59
Yasir Ijaz's user avatar
Yasir Ijaz
1,06311 gold badge1616 silver badges2020 bronze badges
4
This is the only (and simplest) answer that worked for me. –
smolo
CommentedOct 5, 2022 at 16:16
What nonsense is this? If I'm not able to start MySQL server then how this "mysqlcheck -r --databases
mysql --use-frm" will work? –
Sk Suraj
CommentedApr 8, 2023 at 6:36
This worked like a charm for me as well. So glad I could use some mysql commands to do the needed
repairs directly, rather than fancy file manipulation involving the backup folder and hoping I didn’t screw it
up! –
John Larson
CommentedDec 22, 2023 at 15:10
@SkSuraj Try it. It will work. –
Yasir Ijaz
CommentedDec 24, 2023 at 14:57
mysqlcheck: Got error: 2002: Can’t connect to MySQL server on ’localhost’ (10061) when trying to
connect –
Moeez
CommentedMay 30, 2024 at 9:48
Show 3 more comments
48

Go to mysql/data/
Delete all random files (except the actual database folders)
Restart Apache and MySQL.
It should fix it.

Share
Improve this answer
Follow
edited Jan 21, 2016 at 13:06
answered Jan 21, 2016 at 12:55
Kerim Tim.’s user avatar
Kerim Tim.
1,1591212 silver badges1313 bronze badges
25
It deleted all my data. There was a lot of data. –
Paras
CommentedMar 17, 2017 at 11:08
19
I confirm that deleting files will make all DB unusable. Table files are there but they can’t display. –
Adrian P.
CommentedApr 25, 2018 at 0:27
No Luck... Still having the same issue. –
Thirsty Six
CommentedFeb 28, 2022 at 5:28
9
Dont TRY this! 100% deletes all your databases, –
Anirudh babbar
CommentedJul 12, 2022 at 9:47
1
Why is this answer upvoted? –
mrconcerned
CommentedDec 9, 2022 at 9:16
Add a comment
44

UPDATE APRIL (2022)


Rename folder mysql/data to mysql/data_old
Make a copy of mysql/backup folder and name it as mysql/data
Copy all your database folders and mysql folder from mysql/data_old into mysql/data
Copy mysql/data_old/ibdata1 file into mysql/data folder
Start MySQL from XAMPP control panel

REFERENCE

https://www.youtube.com/watch?v=ipMedkjMupw&ab_channel=GeekyScript

Share
Improve this answer
Follow
edited Apr 6, 2022 at 0:58
answered Apr 6, 2022 at 0:52
John Nico Novero’s user avatar
John Nico Novero
67366 silver badges1010 bronze badges
4
It is working for me. I have faced this problem second time. –
Bhavin Thummar
CommentedMay 11, 2022 at 7:18
1
this might be the answer i’m looking for. thanks! –
Jonathan Jeshua Laniba
CommentedMar 10, 2024 at 5:17
1
It is a working solution –
Toton
CommentedJul 31, 2024 at 5:58
best answer, works for me on windows 11 in 2024 –
Mohit Rane
CommentedSep 8, 2024 at 10:01
Add a comment
38

Just follow two steps

go to xampp\mysql\backup copy everything from backup folder

go to xampp\mysql\data paste everything in data folder copied from backup folder

Thats all.

Also follow the video description to fix without losing any data:

https://www.youtube.com/watch?v=hB1wshpP3Jc

Or follow the article description to fix without losing any data:

https://webjourney.dev/error-mysql-shutdown-unexpectedly-solve-without-loosing-any-data-webjourney

Share
Improve this answer
Follow
edited Dec 17, 2022 at 17:06
answered Sep 16, 2021 at 7:30
Nazmul Hoque’s user avatar
Nazmul Hoque
9701111 silver badges1010 bronze badges
This answer will fix the above error but will also cause another errror, your django migration table in your
database will disappear, thus you’ll get the error django_migration table does not exist –
C-Bizz
CommentedOct 20, 2021 at 3:32
This is because you have delete ibdata1 form your data directory. I have also mentioned follow the
description link for solve without losing any data. –
Nazmul Hoque
CommentedOct 20, 2021 at 5:30
Add a comment
25

When you’re not running 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.

You can delete ibdata1 as 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.

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.

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.

Share
Improve this answer
Follow
answered Nov 7, 2013 at 15:37
Ryan Williams’s user avatar
Ryan Williams
70566 silver badges1111 bronze badges
1
This should be accepted as correct answer. If you remove ibdata1, there will be tons of orphaned tables.

sean
CommentedMar 3, 2015 at 20:05
Thanks, you fixed my problem after trying a ton of different things. –
Bryan Miller
CommentedDec 23, 2015 at 21:42
also fixed issue for me –
Gaz Smith
CommentedApr 29, 2019 at 8:36
Nice explannation :D Thank you. –
logbasex
CommentedJun 4, 2020 at 3:21
The ’Restore previous versions’ option only works if you regularly create Restore Points in Windows. :( –
nockieboy
CommentedJun 9, 2020 at 9:04
Show 3 more comments
24
I have tried all of the previous answers, but it didn’t work for me. So finally I tried the below approach and
it worked 100% for me.

If you are worried about following the below steps, you can take a backup of the entire XAMPP folder for
the safe side.

Step 1: Rename the c:\xampp\mysql\data folder to c:\xampp\mysql\data_bkp

Step 2: Create a new folder c:\xampp\mysql\data.

Step 3: Copy the content, that is present inside c:\xampp\mysql\backup to the new c:\xampp\mysql\data
folder.

Step 4: Copy all your database folders c:\xampp\mysql\data_bkp to c:\xampp\mysql\data (Note: Don’t
copy mysql, performance_schema, and phpmyadmin folders).

Step 5: Copy the ibdata1 file from c:\xampp\mysql\data_bkp and replace it inside the c:\xampp\mysql\data
folder.

Step 6: Start MySQL from the XAMPP control panel.

Share
Improve this answer
Follow
edited Dec 4, 2023 at 21:10
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Mar 6, 2022 at 10:50
Soubhagya Kumar Barik’s user avatar
Soubhagya Kumar Barik
2,6052424 silver badges3131 bronze badges
Thanks, @haider. be careful while doing the above steps. –
Soubhagya Kumar Barik
CommentedMar 12, 2022 at 13:28
1
Thanks I am exploring from last 2 hours, you save my time. –
Assad Yaqoob
CommentedMar 28, 2022 at 17:43
does not work for me –
Muhammad Sarmad Mahmood Malik
CommentedOct 8, 2022 at 8:55
May I know what exactly you are facing @MuhammadSarmadMahmoodMalik –
Soubhagya Kumar Barik
CommentedApr 12, 2024 at 16:52
That worked for me too! –
Nur Uddin
CommentedOct 23, 2024 at 7:02
Add a comment
24

Recovering a crashed Database

Instead, first try using the MySQL backup folder which is included with XAMPP. So do the next steps:
Rename folder mysql/data to MySQL/data_old

Make a copy of MySQL/backup folder and name it as MySQL/data

Copy all your database folders from MySQL/data_old into mysql/data (except MySQL,
performance_schema, and phpmyadmin folders)

Copy MySQL/data_old/ibdata1 file into mysql/data folder

Start MySQL from the XAMPP control panel

Share
Improve this answer
Follow
edited Mar 13, 2024 at 6:03
answered Oct 14, 2022 at 9:40
Charles Thembo’s user avatar
Charles Thembo
65666 silver badges77 bronze badges
2024 - worked for me –
Linesofcode
CommentedApr 7, 2024 at 15:25
Add a comment
17

Never delete this file (ibdata1), because all your data will be deleted!!!

I suggest three ways:

A:

Exit from the XAMPP control panel.


Rename the folder mysql/data to mysql/data_old (you can use any name)
Create a new folder, mysql/data
Copy the content that resides in mysql/backup to the new mysql/data folder
Copy all your database folders that are in mysql/data_old to mysql/data (skipping the mysql,
performance_schema, and phpmyadmin folders from data_old)
Finally copy the ibdata1 file from mysql/data_old and replace it inside mysql/data folder
Restart your system.
B:

Stop all SQL Server services.

Next, start all SQL Server services again.

Enter image description here

C:

Open the XAMPP control panel

Click on the Config button. In front of MySQL, click on my.ini

Enter image description here


Change the client port and server port.

Enter image description here

Share
Improve this answer
Follow
edited Nov 10, 2023 at 3:54
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Nov 28, 2020 at 8:28
Rasul Ebrahimzadeh’s user avatar
Rasul Ebrahimzadeh
30633 silver badges1212 bronze badges
2
Changing port worked for me and no other method worked –
Zobia Kanwal
CommentedDec 18, 2020 at 13:09
3
This is the best answer. Everyone should follow this –
Al Mahdi
CommentedMar 5, 2022 at 14:22
1
It is ok now after changing port. thanks. –
Htoo Htet Oo
CommentedFeb 17, 2023 at 6:15
1
Thank you so much, worked even i didnt followed A and B step. –
Muhammad Ali
CommentedMar 21, 2023 at 6:35
Add a comment
16

I got the same kind of error in my C:\xampp\mysql\data\mysql_error.log when trying to start 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_database is preventing MySQL from starting.

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

Make sure MySQL and XAMPP is shut down completely.


Go to your directory where MySQL is installed, mine is: C:\xampp\mysql\data
You should see a folder with the name of a database that you created. mine was test_database.
Create a new folder somewhere else called C:\xampp\mysql\data\mysql\backuptablespace
Drag and drop (don’t delete) the offending database table folder to the backup directory.
Try to start MySQL again. For me, it started right up in one second as expected.
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:

Make a clone of the entire C:\xampp\ and store it somewhere safe so you can get back to where you
started.

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.

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.

Try removing these files from C:\xampp\mysql\data\mysql: db.frm db.MRD db.MYI db.opt user.frm
user.MYD user.MYI

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.

Nuclear option:

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

Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:06
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Aug 8, 2013 at 17:25
Eric Leschinski’s user avatar
Eric Leschinski
154k9696 gold badges422422 silver badges337337 bronze badges
Add a comment
15

Add the following line below the [mysqld] section in the MySQL configuration file (my.ini). Restart the
Apache web server and the MySQL service afterwards.

[mysqld]
innodb_force_recovery = 4
Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:31
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Dec 16, 2013 at 17:40
aog’s user avatar
aog
50433 silver badges1414 bronze badges
7
Read about what you are doing, before you do it:
dev.mysql.com/doc/refman/5.0/en/forcing-innodb-recovery.html –
marcovtwout
CommentedSep 30, 2014 at 11:56
6
it’s better to start with value 1 and increment it each time it didn’t work. Values 1-3 are considered save.
4-6 can corrupt data! –
CoR
CommentedAug 18, 2015 at 20:26
This helped me. As pointed out, use values 1-3 first. 2 worked on me. I had to dump all my database,
reset mysql data using the back up folder then import the dumps. This is helpful if you want to keep your
data –
claw68
CommentedSep 13, 2020 at 5:42
Add a comment
14

My Xampp MySQL worked just follows as below:

01.Go to mysql/data/ directory


02. delete the ibdata1 & ib_logfile*(ib_logfile0,ib_logfile1,ib_logfile101) file
03. restart xampp server
Share
Improve this answer
Follow
answered Dec 4, 2016 at 9:45
matinict’s user avatar
matinict
2,49022 gold badges2727 silver badges3535 bronze badges
Don’t do it. From official manual "Directly editing or moving the redo logs can cause corruption, and
should never normally be attempted." –
danblack
CommentedJul 29, 2024 at 23:34
Add a comment
14

Step 1 : Close Xampp controller completely


Step 2 : Open C:\xampp\mysql\backup
Step 3 : Copy all the files from backup folder
Step 4 : Open C:\xampp\mysql\data
Step 5 : Paste the all the files in data folder
Step 6 : Re-start the Xampp controller

Share
Improve this answer
Follow
edited Dec 10, 2020 at 17:14
Cristik’s user avatar
Cristik
32.9k2626 gold badges102102 silver badges141141 bronze badges
answered Dec 10, 2020 at 14:41
Swap’s user avatar
Swap
16522 silver badges1010 bronze badges
Thanks man worked like a charm for me. :) –
Utpal - Ur Best Pal
CommentedDec 16, 2020 at 6:46
Thanks this solve the issue but we need to keep old ibdata file, else we will lose the data –
Kenana Reda
CommentedAug 12, 2021 at 11:27
1
Never do that. I have lost my data. –
Shiva
CommentedAug 23, 2021 at 5:34
Add a comment
10

STOP! Please do NOT delete ibdata1 file!

Deleting this file is like playing Russian roulette with your databases, it could work and re-establish
everything, but also, it could leave every database you have unusable.

Instead, first try using the MySQL backup folder which is included with XAMPP. So do the next:

Rename the folder mysql/data to mysql/data_old (you can use any name)
Create a new folder mysql/data
Copy the content that resides in mysql/backup to the new mysql/data folder
Copy all your database folders that are in mysql/data_old to mysql/data (skipping the mysql,
performance_schema, and phpmyadmin folders from data_old)
Finally:

copy the ibdata1 file from mysql/data_old and replace it inside mysql/data folder
Start MySQL from XAMPP control panel
Share
Improve this answer
Follow
edited Jan 17, 2023 at 22:28
Klaassiek’s user avatar
Klaassiek
2,90611 gold badge2525 silver badges4444 bronze badges
answered Oct 13, 2021 at 6:06
Hasitha’s user avatar
Hasitha
15922 silver badges1313 bronze badges
This is the only proposed workaround that worked for me without losing the last improvements of my DB
data model. Thank you. –
fede72bari
CommentedAug 3, 2022 at 8:08
This seems to have been plagiarised from Rasul Ebrahimzadeh’s answer. Or there is a common source it
has been plagiarised from. –
Peter Mortensen
CommentedDec 4, 2023 at 20:01
You are right. And this solution worked for me. Don’t order to take backup of data folder first. –
Murtaza Bharmal
CommentedAug 3, 2024 at 7:16
Add a comment
10

I also faced this issue and this is how I solved it.


Make sure directory "xampp" is not under a subdirectory. For example, it should be "C:\xampp"
You might need to run as administrator in running the application.
Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:28
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Aug 13, 2013 at 18:31
SITHU’s user avatar
SITHU
16377 bronze badges
Add a comment
10

Copy all files from folder xampp/mysql/backup/ and then paste them into folder /xampp/mysql/data/
Restart MySQL.
Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:42
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Jan 28, 2020 at 10:20
Khandaker Toihidul Islam’s user avatar
Khandaker Toihidul Islam
50955 silver badges88 bronze badges
Nothing worked on this topic but your method worked very well. Thanks –
Codecopath
CommentedAug 31, 2022 at 18:20
I had the same issue and implemented almost every above solution but nothing happened. And Tried
your solution It worked perfectly. Most importantly I just want to add one more thing to it. After
copy-pasting the files and folder from the Backup folder to the data folder. For the sake of old databases
what we have to do we just have to create the backup of databases before copy-pasting but after
copy-pasting we just copy the database folders and from the backup and paste them inside the data
folder. In this way, we are able to use our old databases too. –
M Mamoon Khan
CommentedOct 28, 2022 at 6:36
Yes nothing on this topic above worked for me. I tried your solution and it works like charm. Thanks man.
I also agreed with @MMamoonKhan suggestion on backing up your data. –
Julius Fasema
CommentedSep 29, 2023 at 4:26
Add a comment
10

Move the files from folder xampp/mysql/backup into folder xampp/mysql/data


Run XAMPP as Administrator(make sure MySQL is installed. You can see a green tick if is installed)
List item

Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:58
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered May 16, 2020 at 21:36
Jayant Rajwani’s user avatar
Jayant Rajwani
8331010 silver badges1818 bronze badges
THIS FIXED IT FOR ME. If you’re running Xampp on windows, make sure you are running Apache and
MySql AS A SERVICE. If you don’t see the green tick, Click the red X to run the servers as a service. –
dividedbyzero
CommentedMay 28, 2023 at 8:46
Add a comment
7

in my case i did following steps and it worked:

In Xampp control panel click on "Services" button from the right side toolbar

Then find "MySQL" from the services List

Click on it and from the left side of the panel click on "stop"

Turn back in Xampp control panel and click on start.

Share
Improve this answer
Follow
edited Dec 3, 2019 at 10:40
tomerpacific’s user avatar
tomerpacific
6,5101818 gold badges4141 silver badges6060 bronze badges
answered Dec 3, 2019 at 8:54
Sobhan’s user avatar
Sobhan
1,46011 gold badge2020 silver badges3737 bronze badges
1
Thank you, none of the other options worked for me, this one did. Very grateful –
user3808307
CommentedJan 27, 2020 at 19:58
@user3808307 I’m glad it helped you :) –
Sobhan
CommentedJan 28, 2020 at 6:28
thank you so much! this was really simple to do and it worked :) –
Aditi
CommentedFeb 25, 2021 at 6:35
Add a comment
7

I have resolved the problem by ending the task for mysqlid in Task Manager.

Enter image description here

Share
Improve this answer
Follow
edited Oct 26, 2023 at 13:37
Peter Mortensen’s user avatar
Peter Mortensen
31.6k2222 gold badges110110 silver badges133133 bronze badges
answered Dec 17, 2019 at 6:56
Mandeep Singh Gill’s user avatar
Mandeep Singh Gill
1,3451010 silver badges55 bronze badges
Add a comment
7

I had the same problem for a while. While most suggestions worked, I had to reinstall XAMPP and copy
the files and table folders from xampp\mysql\data to the new installation.

However, I found a way easier fix.

enter image description here

I noticed the issue was linked to how I exited XAMPP. Shutting down my PC without stopping the services
first caused problems.

When reinstalling XAMPP, only two files were present ibdata1 and my.ini before starting the service. After
starting it, temp files were generated.

When the issue recurred a week or so later, I deleted all temp files except the original two ibdata1 and
my.ini, and just like that XAMPP started working, without the need to restart and without copy and pasting
any files.

enter image description here

enter image description here

Share
Improve this answer
Follow
edited Jul 6, 2024 at 7:58
answered Jan 25, 2024 at 4:05
Alohe’s user avatar
Alohe
47077 silver badges1515 bronze badges
Add a comment
6

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.

Share
Improve this answer
Follow
answered Jan 11, 2017 at 15:18
kyzen’s user avatar
kyzen
31311 gold badge33 silver badges1515 bronze badges
This is not a valid answer! –
abhiarora
CommentedJan 11, 2017 at 15:37
Not valid answer –
Soumyajit Dutta
CommentedAug 1, 2019 at 15:10
I can’t find the MySql service in my system. –
Thirsty Six
CommentedApr 28, 2022 at 11:46
Add a comment
6

Here is the way you can solve this problem:

Go to C:\xampp\mysql\data
You will see a folder named as mysql/data
Rename that folder from mysql/data to something else like mysql/data_not_useful any name that you
want to give.
Create a new folder named as mysql/data.
Copy all the files of the mysql/backup and paste in mysql/data.
Now go to mysql/data_not_useful and copy the file ibdata1 from there.
Then paste it in mysql/data (You have to replace the file).
Restart your xampp server.
Now run your mysql server.
Share
Improve this answer
Follow
edited Apr 30, 2021 at 20:59
Tomerikoo’s user avatar
Tomerikoo
19.4k1616 gold badges5454 silver badges6767 bronze badges
answered Apr 30, 2021 at 11:31
Akash Kumar’s user avatar
Akash Kumar
32711 gold badge44 silver badges1010 bronze badges
Amazing .Your answer woking fine .Thank you so much –
Ganesan J
CommentedJan 3, 2022 at 9:37
In my case I followed your answer and delete all info file type .After that I got my lost database –
Ganesan J
CommentedJan 3, 2022 at 10:00
Add a comment
6

Go to xampp/mysql/data

Rename folder from data to data_backup


Create new folder data
Copy files from backup to data
delete ibdata1 from data folder
Copy ibdata1 from data_backup folder to data folder
Copy your all database from data_backup to data folder
Restart xampp. It will start working
Share
Improve this answer
Follow
edited Aug 1, 2022 at 6:29
answered Aug 1, 2022 at 6:20
Rehan Rajpoot’s user avatar
Rehan Rajpoot
18622 silver badges88 bronze badges
Add a comment
6

# The MySQL server


default-character-set=utf8mb4
[mysqld]
skip-grant-tables // Place this line here
port=3306
socket="C:/xampp/mysql/mysql.sock"
basedir="C:/xampp/mysql"
tmpdir="C:/xampp/tmp"
datadir="C:/xampp/mysql/data"
pid_file="mysql.pid"
# enable-named-pipe
key_buffer=16M
max_allowed_packet=1M
sort_buffer_size=512K
net_buffer_length=8K
read_buffer_size=256K
Open my.ini file from C:\xampp\mysql\data

skip-grant-tables place this line before port and restart and it working

Share
Improve this answer
Follow
edited Dec 16, 2022 at 8:29
duncan’s user avatar
duncan
31.9k1515 gold badges8181 silver badges101101 bronze badges
answered Oct 13, 2021 at 3:16
Jignesh Patel’s user avatar
Jignesh Patel
31622 silver badges1111 bronze badges
Add a comment
6

I had the same issue.

Step 1
backup folder xampp/mysql/data (saved it as ‘xampp/mysql/_old_data‘).

enter image description here

You might also like