How can I solve "Error: MySQL shutdown unexpectedly"? [closed]
Asked Answered
S

89

534

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?

Sheenasheeny answered 2/8, 2013 at 17:27 Comment(3)
I just deleted info files in my xampp\mysql\data\ folder and it works for me.Corpora
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?Bedding
@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 :-/Howsoever
L
2008

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:

  1. Rename folder mysql/data to mysql/data_old
  2. Make a copy of mysql/backup folder and name it as mysql/data
  3. Copy all your database folders from mysql/data_old into mysql/data (except mysql, performance_schema, and phpmyadmin folders)
  4. Copy mysql/data_old/ibdata1 file into mysql/data folder
  5. 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.

Lasky answered 17/5, 2020 at 22:20 Comment(40)
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 https://mcmap.net/q/73618/-how-can-i-solve-quot-error-mysql-shutdown-unexpectedly-quot-closed refers to innodb_force_recoverySedulity
I've resorted to this answer sooo many times that I even wrote a PowerShell script to automate the process: gist.github.com/josemmo/24e35f2b4984a4370ce2c164f5956437Skiffle
As per @Skiffle gist, it's important to note to exclude mysql, performance_schema, phpmyadmin when copying directories to mysql/dataCopyboy
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?Merridie
I installed the newest version of XAMPP. It was working fine for a while. Now again MySQL stopped working and I am getting the same error message. Is there something wrong with XAMPP? Why recently I've got this problem with XAMPP?Merridie
Somebody should try just deleting the buffer and log files. I have a nudge that might be an even faster fix.Jesus
Sadly I've been experiencing this problem way to constantly -each 15 days or so- even though I'm openning Xampp as admin and closing it before shutdown. I'll try also shutting it down whenever I sleep pc to see if it is related to that.Lemmon
It worked , but it happens too often . Does anyone why this is happening so often ?Anticyclone
Best answer ever. My mysql at xampp 7.1 just stopped to work, no reason no error in log. This happened second time (on wordpress database) . First time i ended up importing all databases + reinstall, now tried this, and worked fabulously, saved my day man :)Gammer
Machine crashed, Database seems to be stucked. Every time I want to start the MySQL via XAMPP it shuts down instantly again. This trick fixed m issues without any data loss, That's a +1 from me !Nation
MySQL service started but accessing phpmyadmin results in " MySQL said: Documentation Cannot connect: invalid settings. mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server." Any ideas how to solve this? Thanks!Kendry
In Addition to the answer: copy all folders from mysql/data_old to mysql/data to get all the database back.Alphorn
I have had xampp mysql stop working seemingly randomly a few times. It's most often after I restart for whatever reason, but I feel like each time is after a Windows Update. Regardless, this saved my rear once. It has not worked each time, but the one time it worked is enough for me to say THANK YOU!Uruguay
Looks like it Worked for so many people but unfortunately it didn't work for me. And i was randomly into those folders so what i did was (I also make a copy of data folder it's important because after installation all those data folder will be complete fresh) I went inside xampp/mysql/bin folder there i nagivate to mysql_install_db and it works fine.Albumose
I worked, but you have also to skip the folder "test" in Step 4.Hohenlinden
All these solutions delete your existing User Data.Tilbury
I had done the same steps but still the same problem and after that, i change the port from 3306 to 3308 and its start working thanks a lotSeasickness
it worked but I couldn't connect to the DB until I changed the DB User in all my websites to "root" and Password to "". What could be the reason?Woodcock
This worked, but only after I copied ALL the files in "mysql/" (but I still excluded mysql/mysql/, mysql/performance_schema/, and mysql/phpmyadmin/ folders. Failing to copy all the files, and not just ibdata1, resulted in phpmyadmin complaining that "mydatabase.mytable doth not exist" for every one of my tables in all my databases. I don't know which file inspecific I missed (I made sure to copy ibdata1 but that wasn't sufficient on its own), so maybe this answer could be updated to clarify which ones I should've copied? I'm ignorant here.Ehrsam
No use, still keep repeating the same issue after few days.Jodeejodhpur
It's not working for me. This is the actual issue "mysqld.exe: Table '.\mysql\db' is marked as crashed and should be repaired" - I solved it used this method https://mcmap.net/q/74835/-mysqld-exe-table-39-mysql-db-39-is-marked-as-crashed-and-should-be-repairedJodeejodhpur
Thanks, it solved my problem. youtube.com/watch?v=NFZM0w85g2MIndissoluble
thanks a lot, it works to me. In step 3, make sure to skip files that already exist...do not replace otherwise it would not work.Jordan
This is indeed a correct answers and works 100% for almost all the scenarios of mysql not turning on through xampp. There are several more answers posted, but nobody actually talks about why this error occurs, what can be done to prevent this and why xampp is not fixing it. Would love if someone can shed some light on these points.Edina
Also remember to skip the files otherwise it won't work. It should be mentioned in the answer.Olson
It didn't worked for me, unfortunately. When I copy my database folders (except mysql, performance_schema, and phpmyadmin folders) and ibdata1 file, it encounters same error. Please be noted that the fresh copy of backup > data works fine. What else I can try? Or, How can I detect what is the issue exactly?Urolith
The above solution will work just fine. But there's a catch, after few days or months it'll again show the same error. Also some of the databases may get corrupted while doing this. I believe it's better to reinstall xampp again.Dmitri
It works for me, but the error keeps repeating after days or weeks, this solutions works fine but this is not the permanent solution.Springing
This worked 2x for me but today it failed and I can't start MySQL, means I lost my databases. @fabrizio do you think new XAMPP installation solves this? What a crap, I can't believe they had such a big bug. Cost me so many nerves that I am thinking of switching to Ubuntu just because of this XAMPP/MySql crash.Bibbie
this didn't work with me at first. But it worked when on step 3, when copying the database folders, when prompted to replace existing files, we should click on skip not replace.Clasp
It worked for me, but my root password was reset to "". I have set it back to original value through phpmyadmin and everything is now back to normal.Dragonfly
This is working, but does this have any permanent solution? Because after backing up & reinstalling xampp I am getting this error again after few days of use. It's like a loop. I'm unable to find any permanent solution for this. Does my machine is not ok for xampp or what?Pandanus
In my case this problem occurs when I use "Autostart of mudules" feature. Since I've stopped using "Autostart of mudules", this issue is gone. But if you are having this issue, first you have to fix this. After fixing this avoid using "Autostart of mudules", because since I've stopped using "Autostart of mudules", the problem is gone.Pandanus
Sometimes this does not work but here is a link to a video with almost the same solution. Just a few tweaks; youtube.com/watch?v=84IOtc05TuA&ab_channel=BoostMyToolEventuality
Well, the day has come. Usually this solution worked but today it has not. And i am pretty sure all my data got yeeted. Cool, what a piece of shit softwareCorduroys
By doing this dbs and tables are restored successfully but functions and procedures couldnot be restored, is there anyway to restore functions and procedures too?Attraction
For me, using XAMPP V3.2.4, copy mysql/data to somewhere else as backup of corrupted data and all your data is here. Then, i create a new mysql/data folder. Then copy all from mysql/backup to the new empty mysql/data folder. Then I copy all data EXCEPT mysql,performance_schema, phpmyadmin AND ibdata1 from the original mysql/data into the new mysql/data folder. OVERWRITE any existing files. THEN, I copy ibdata1 from the original mysql/data to the new mysql/data and overwrite it. Able to start back mysql and all my web applications runs without any problems.Chafee
worked like a magicBillyebilobate
works as a charm :)Radburn
works like a charm :) thanks. Since this is a temporary solution, reintalling XAMPP will not affect database?Sidereal
A
239

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

I just did this and it worked:

  1. exit Xampp server
  2. go to your C:\xampp\mysql\data directory
  3. delete the ibdata1 file
  4. restart xampp server

It should work.

Amathiste answered 10/8, 2013 at 13:14 Comment(18)
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.Rutland
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.Tugman
I added innodb_force_recovery = 1 within [mysqld] section, in my mysql configuration file, restarted mysql, and then removed the line, this worked!Clemence
I also had to delete ib_logfile0 and ib_logfile1 to get it to workAgglutinative
I had to delete all of these files: mysql_error.log aria_log.00000001 aria_log_control ib_logfile0 ibdata1Nepenthe
Ouch! Blowing away ibdata1 is equivalent to losing all your data (or at least all that are ENGINE=Innodb !Actual
The most upvoted unexplained reckless thing you can doPass
Deleting mysql_error.log aria_log.00000001 aria_log_control ib_logfile0 ibdata1 did not work. I deleted all files except folders in C:\xampp\mysql\data to let it work again :) !Committal
It should not be this way. Ok there are some corrupted files, but you should use the backup folder to restore everything, such as the XAMPP control message panel suggest. This could be a better way of doing it: https://mcmap.net/q/73618/-how-can-i-solve-quot-error-mysql-shutdown-unexpectedly-quot-closedLasky
Fabrizio Valencia's answer (#18023309) is the only one that worked for me (and it was non-destructive). Highly recommend.Arnettearney
This might "work" in that you can restart MySQL, but it will no doubt result in more headaches as your db will be gone. See the answer that begins with "Stop there! Please do not delete anything!"Reena
This broke my database. See the answer from Fabrizio Valencia.Guard
this worked just fine, xampp refused to run SQL after fresh installing, so there is no database to worry about, nothing other than this worked.Pignut
Still works in 2021. I must give you credit for this. Spent almost half a day looking for solution (using the wrong search terms). Thanks for this.Holdall
I tried this, it's working.. after some time it's showing the same issue.. even i changed the mysql port.. No Luck.Jodeejodhpur
It did not solve my problem.Jurkoic
Seleting anything anything is disastrous, so i don't recommend this answerPositron
Table '****' doesn't exist in engineFirstnighter
A
134

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)

  1. Stop MySQL.
  2. Go to the C:/xampp/mysql directory and copy the data folder and keep it somewhere else (probably in another drive) as a backup.
  3. Go to your original data folder (C:/xampp/mysql) and sort the files by 'Type.'
  4. Select the files that have the type INFO File and delete them (screenshot below).
  5. 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.

Andri answered 22/12, 2021 at 5:56 Comment(19)
Still the same error occurLovegrass
Worked for me, running xampp 7.4.16Inotropic
I have tried top voted answer first. But that did not work for me. after making the changes according to that answer, I tried your answer and it worked. Now should it need to undo those previous changes?Oui
Although this works, be careful, as it makes the tables un-readable and all data is gone.Mohamed
@Mustafasabir I still have all the data after doing this.Andri
Can u access the tables? When I try to access it given error. Export also does not work.Mohamed
@Mustafasabir yes i can access the table and it works just like before.Andri
Thanks, worked for me in xammp v8.1.6 . Please summarize it a little :)Josh
Worked for me in xampp v3.3.0. Thank you so muchPalpebrate
It doesn't work for me xampp v3.3.0 : <Semela
@MythVince Mmm, it's strange. Albert Ruelan (the comment above you) has the same version and he said it works.Andri
nah just found the other issue away around.Semela
Thanks, tried all above solutions but your solution worked for me.Aramenta
Deleting INFO File are solve the issueGiguere
I never had this problem wit EasyPhp but it always happen with xampp !!Aphrodisia
Worked for me in xampp v3.3.0. Thank you.Sleepless
Instead of piling on, it would be better if the answer appears as if it was written today (for example, tagging parts with version ranges / data ranges if they only apply to particular versions. And remove outdated parts). There is a full version history of this answer, so nothing is lost.Bedding
Deleting the INFO file actually worked! Beast!Clegg
Definitely the right solution... xampp 3.3.0 Win10 x64Lear
M
91

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.

Marybethmaryellen answered 28/1, 2020 at 2:36 Comment(0)
I
68

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.

Intine answered 28/5, 2021 at 6:47 Comment(10)
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.Andri
@Andri I have tested it on my machine having 10+ database tables. Nothing breaks for me. By the ways thanks for letting me know about this.Intine
It works for me. No database lost. One of the best answer.Olson
Only this post has solved my Mysql problem. Best one here. Thanks so much, man.Leister
Your welcome @Leister . We rise by lifting other.Intine
It's best of both worlds!Compiler
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).Dragelin
Great solution! Worked perfectly. Thank youFebruary
This seems to have been plagiarised from Rasul Ebrahimzadeh's answer. Or there is a common source it has been plagiarised from.Bedding
This is the working solution thanksHelle
I
50
  1. Go to mysql/data/
  2. Delete all random files (except the actual database folders)
  3. Restart Apache and MySQL.

It should fix it.

Incite answered 21/1, 2016 at 12:55 Comment(5)
It deleted all my data. There was a lot of data.Immunity
I confirm that deleting files will make all DB unusable. Table files are there but they can't display.Ministrant
No Luck... Still having the same issue.Jodeejodhpur
Dont TRY this! 100% deletes all your databases,Childish
Why is this answer upvoted?Jurkoic
F
37

Just follow two steps

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

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

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

Fiddlewood answered 16/9, 2021 at 7:30 Comment(2)
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 existChemesh
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.Fiddlewood
Y
36

UPDATE APRIL (2022)

  1. Rename folder mysql/data to mysql/data_old
  2. Make a copy of mysql/backup folder and name it as mysql/data
  3. Copy all your database folders and mysql folder from mysql/data_old into mysql/data
  4. 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

Yep answered 6/4, 2022 at 0:52 Comment(2)
It is working for me. I have faced this problem second time.Colombi
this might be the answer i'm looking for. thanks!Beebread
T
31

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.

Taxeme answered 16/9, 2022 at 5:59 Comment(5)
This is the only (and simplest) answer that worked for me.Oral
What nonsense is this? If I'm not able to start MySQL server then how this "mysqlcheck -r --databases mysql --use-frm" will work? 😂Pandanus
works for me tooChoirmaster
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!Muskellunge
@SkSuraj Try it. It will work.Taxeme
N
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.

Norty answered 7/11, 2013 at 15:37 Comment(8)
This should be accepted as correct answer. If you remove ibdata1, there will be tons of orphaned tables.Surah
Thanks, you fixed my problem after trying a ton of different things.Sliding
also fixed issue for meEphebe
Nice explannation :D Thank you.Z
The 'Restore previous versions' option only works if you regularly create Restore Points in Windows. :(Communicant
Windows should be backing up file changes separately. I have system restore disabled in Windows 10 but I still get previous version history of changed files. I’m not sure what logic exactly drives this — for example does it only occur on sizes below a certain size, etc.Norty
The answer is great apart from one thing: I still got the issue while I always run XAMPP as administrator. So that is not the sole cause of the corruption.Jesus
THIS should be selected as the right answer.Turbot
P
16

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

I suggest three ways:

A:

  1. Exit from the XAMPP control panel.
  2. Rename the folder mysql/data to mysql/data_old (you can use any name)
  3. Create a new folder, mysql/data
  4. Copy the content that resides in mysql/backup to the new mysql/data folder
  5. 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)
  6. Finally copy the ibdata1 file from mysql/data_old and replace it inside mysql/data folder
  7. Restart your system.

B:

  1. Stop all SQL Server services.

  2. Next, start all SQL Server services again.

    Enter image description here

C:

  1. Open the XAMPP control panel

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

    Enter image description here

  3. Change the client port and server port.

    Enter image description here

Purulent answered 28/11, 2020 at 8:28 Comment(4)
Changing port worked for me and no other method workedGabbert
This is the best answer. Everyone should follow thisMiffy
It is ok now after changing port. thanks.Strath
Thank you so much, worked even i didnt followed A and B step.Peroxidase
M
16

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.

Mccready answered 6/3, 2022 at 10:50 Comment(4)
Thanks, @haider. be careful while doing the above steps.Mccready
Thanks I am exploring from last 2 hours, you save my time.Bolus
does not work for meElater
May I know what exactly you are facing @MuhammadSarmadMahmoodMalikMccready
S
15

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:

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

  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.

Nuclear option:

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

Seamus answered 8/8, 2013 at 17:25 Comment(0)
B
14

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
Berk answered 16/12, 2013 at 17:40 Comment(3)
Read about what you are doing, before you do it: dev.mysql.com/doc/refman/5.0/en/forcing-innodb-recovery.htmlCollbaith
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!Vector
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 dataCopyboy
J
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

Jello answered 10/12, 2020 at 14:41 Comment(3)
Thanks man worked like a charm for me. :)Grivet
Thanks this solve the issue but we need to keep old ibdata file, else we will lose the dataNightie
Never do that. I have lost my data.Elimination
T
13

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
Thereabouts answered 4/12, 2016 at 9:45 Comment(0)
C
10

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

  1. Make sure directory "xampp" is not under a subdirectory. For example, it should be "C:\xampp"
  2. You might need to run as administrator in running the application.
Cuthburt answered 13/8, 2013 at 18:31 Comment(0)
P
10
  1. Move the files from folder xampp/mysql/backup into folder xampp/mysql/data
  2. Run XAMPP as Administrator(make sure MySQL is installed. You can see a green tick if is installed)

List item

Physiological answered 16/5, 2020 at 21:36 Comment(1)
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.Pigmy
A
9

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
Antetype answered 13/10, 2021 at 6:6 Comment(2)
This is the only proposed workaround that worked for me without losing the last improvements of my DB data model. Thank you.Onstad
This seems to have been plagiarised from Rasul Ebrahimzadeh's answer. Or there is a common source it has been plagiarised from.Bedding
C
8
  1. Copy all files from folder xampp/mysql/backup/ and then paste them into folder /xampp/mysql/data/
  2. Restart MySQL.
Caveat answered 28/1, 2020 at 10:20 Comment(3)
Nothing worked on this topic but your method worked very well. ThanksSuckerfish
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.Presbyterian
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.Lepp
D
8

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

Diggins answered 14/10, 2022 at 9:40 Comment(1)
2024 - worked for meSunless
U
7

in my case i did following steps and it worked:

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

  2. Then find "MySQL" from the services List

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

  4. Turn back in Xampp control panel and click on start.

Universalize answered 3/12, 2019 at 8:54 Comment(3)
Thank you, none of the other options worked for me, this one did. Very gratefulVergos
@Vergos I'm glad it helped you :)Universalize
thank you so much! this was really simple to do and it worked :)Philippians
T
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.

Tiffie answered 11/1, 2017 at 15:18 Comment(3)
This is not a valid answer!Rahm
Not valid answerBrendon
I can't find the MySql service in my system.Jodeejodhpur
W
6

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

Enter image description here

Wilkey answered 17/12, 2019 at 6:56 Comment(0)
U
6

Here is the way you can solve this problem:

  1. Go to C:\xampp\mysql\data
  2. You will see a folder named as mysql/data
  3. Rename that folder from mysql/data to something else like mysql/data_not_useful any name that you want to give.
  4. Create a new folder named as mysql/data.
  5. Copy all the files of the mysql/backup and paste in mysql/data.
  6. Now go to mysql/data_not_useful and copy the file ibdata1 from there.
  7. Then paste it in mysql/data (You have to replace the file).
  8. Restart your xampp server.
  9. Now run your mysql server.
Unblessed answered 30/4, 2021 at 11:31 Comment(2)
Amazing .Your answer woking fine .Thank you so muchVacillating
In my case I followed your answer and delete all info file type .After that I got my lost databaseVacillating
Q
6

Go to xampp/mysql/data

  1. Rename folder from data to data_backup
  2. Create new folder data
  3. Copy files from backup to data
  4. delete ibdata1 from data folder
  5. Copy ibdata1 from data_backup folder to data folder
  6. Copy your all database from data_backup to data folder
  7. Restart xampp. It will start working
Query answered 1/8, 2022 at 6:20 Comment(0)
T
5

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.

Tantamount answered 17/1, 2017 at 13:33 Comment(0)
E
5
# 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

Ecuador answered 13/10, 2021 at 3:16 Comment(1)
This helped me! Gosh thank you!Inexperience
K
5

I also get the same issue. Solution was kill process Find the PID for port (3306)

netstat -a -n -o | find "3306"

You will see everything you need.

0.0.0.0:3306           0.0.0.0:0              LISTENING       8120   TCP
0.0.0.0:33060          0.0.0.0:0              LISTENING       8120   TCP
[::]:3306              [::]:0                 LISTENING  8120   TCP
[::]:33060             [::]:0                 LISTENING  8120

PID is 8120

Next run the following command

taskkill /PID 8120 /F

Start MySQL again. It will be fine.

Kynthia answered 1/5, 2022 at 21:38 Comment(1)
This worked for me. Guess something was blocking the port..Tilbury
H
4

i was facing the same issue and none of the solutions stated above helped me. i went to the mysql configuration file (my.ini) and changed the port number under [mysqld].By default mysql runs on 3306 port.

port= 3306

i changed it to ,

port= 8111

Then run as Administrator.Finally this worked for me.

Human answered 26/3, 2018 at 7:24 Comment(0)
H
4

This means that you already have a MySQL database running at port 3306.

In the XAMPP control panel, press the 'Config' button and after that press 'my.ini'. After this, Ctrl-F and search for '3306'. Replace any '3306' that you find with a different port number of your choice (you could choose 3307 or 3308 - I chose 2811 and it worked).

After you have replaced every location where '3306' is written, save the file and press 'Start' on the control panel again.

Hirz answered 31/10, 2018 at 12:46 Comment(0)
C
4

I had the same issue.

Step 1

backup folder xampp/mysql/data (saved it as `xampp/mysql/_old_data`).

enter image description here

Step 2

Go to xampp/mysql/data and deleted all the files but not folders! With databases.

enter image description here

Step 3

At this stage your database will not work. You need to go to your backup folder `xampp/mysql/_old_data` and copy over "`ibdata1`" file to `xampp/mysql/data`.

After that everything work as expected including phpmyadmin and console.

Step 4

If this does not help. You can remove xampp/mysql/data folder and rename xampp/mysql/_old_data back to xampp/mysql/data. (ROLLBACK) and try different things.

Calcar answered 13/7, 2021 at 18:21 Comment(0)
S
4

Xampp stop Instantly after start.

copy all files and folder from C:\xampp\mysql\backup and paste into C:\xampp\mysql\data.

enter image description here

Spread answered 2/3, 2022 at 5:10 Comment(0)
I
3
  1. Ctrl + Alt + Del
  2. End task mysqld
  3. Restart MySQL

Intelligencer answered 24/3, 2020 at 18:26 Comment(0)
B
3

I solved a similar MySQL error, and I think this answer will help you to fix the same type of MySQL database error.

MySQL Error on XAMPP Control panel

Solution:

  • Go to the “data” directory in the MySQL database.
  • I installed XAMPP on D: drive on my computer and the MySQL “data” directory location of my computer was “D:\xampp\mysql\data\”. You may have a different location.

Take backup of the MySQL “data” folder

  • First of all, you should create a backup of the “data” folder using any compression software.

  • Give a name like “data_backup.zip” or any type of compression you wish.

  • I used the WinRAR compression software to compress and back up the MySQL “data” folder.

Rename the “data” folder

  • Rename the “data” folder to “data-oldfiles”. This is very important to rename the data directory to any new directory name.

Create a new “data” folder

  • Create a new folder and give the folder name as “data“
  • To solve the problem we need to create a new “data” directory in the MySQL database.

Copy content from the “backup” folder

  • Go to the “backup” folder and copy all files.
  • Paste the files from backup folder to data folder
  • Now start the MySQL database from XAMPP.
  • Your MySQL database will start properly without showing any error.

Transfer all MySQL projects database, data file and log files

  • If you have many database which was used for various projects, then you have to transfer all database from “data-oldfiles” folder to “data” folder.

  • Copy all databases from the data-old files and paste to the data folder.

  • Now you have to copy the data file “ibdata1” & all log files “ib_logfile0, ib_logfile1 ” from data-old files folder to the data folder.

  • If you have many id_logiles then copied all of them.

  • Now start MySQL from XAMPP.

  • Go to phpMyAdmin to check all databases are available and working.

  • Now start your any website project from localhost to check the MySQL database.

The problem is solved!!

MySQL error solved in XAMPP

  • Now you will see the problem is solved and the error message “Error: MySQL shutdown unexpectedly.” will not show again.
  • If you have any question on this issue please feel free to ask any question in the comments section.

You can read the details tutorials on the link below: Error: MySQL shutdown unexpectedly – Solution in 5 easy steps

You can also watch video tutorials to solve the problem:

[Solved] Error: MySQL shutdown unexpectedly

Badr answered 24/7, 2020 at 19:6 Comment(0)
H
3

Error: MySQL shutdown unexpectedly

This is the best answer

  1. Rename the folder mysql/data to mysql/data_old (you can use any name)
  2. Create a new folder mysql/data
  3. Copy the content that resides in mysql/backup to the new mysql/data folder
  4. 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)
  5. Finally copy the ibdata1 file from mysql/data_old and replace it inside mysql/data folder
  6. Start MySQL from XAMPP control panel
Hosfmann answered 11/6, 2021 at 4:55 Comment(1)
This seems to have been plagiarised from Rasul Ebrahimzadeh's answer. Or there is a common source it has been plagiarised from.Bedding
F
3

Go to: C: C:\xampp\mysql

  • Rename the folder "data" to "data_old" (you can use any name).

  • Create a new folder "data".

  • Copy the content of "backup" folder to the new "data" folder.

  • Copy all content of "data_old" to "data" (skip those folder "mysql", "performance_schema", and "phpmyadmin") *** without remplacing the file in the destination (skip theses files)**

  • restart XAMPP

  • And it will work

Feudist answered 30/6, 2021 at 23:21 Comment(1)
skipping files was important. it helped.Columniation
C
2

if you are using MariaDB you can try this:

  1. Go to mysql/data/
  2. Rename aria_log_control to aria_log_control_old
  3. Restart "Mysql"
Cybele answered 28/3, 2018 at 15:0 Comment(1)
I have to do this every time where is the problem from?Damato
F
2

Guys just make sure you dont have MySql Server installed. Because I have MySql server pre-installed and when I start mysql from xampp control panel some port conflicts are happening and its not working.. SO before starting the mysql from xampp control panel make sure mysql server is not installed. I use .net so I have installed mysql server in the Past. Uninstalling it solved my Problem....

Fabrice answered 14/5, 2018 at 7:24 Comment(0)
O
2

What worked for me was (No File Delete):

  1. First I open Logs for MySQL in the XAMPP panel.
  2. At the end, it says you are running another instance of mysqlid in port 3306
  3. I opened my Task Manager (Ctrl + Shift + Esc). Then find mysqlid and End the task.
Ogg answered 1/8, 2020 at 4:32 Comment(0)
D
2

Go to folder C:\xampp\mysql\backup.

Copy all files.

Paste them into C:\xampp\mysql\data.

If Windows asks you to replace some files, replace them.

If your XAMPP Control Panes is active close it.

Go to C:\xampp and find xampp-control. Run it.

Start Apache, and start MySQL.


That's it.

Dammar answered 27/11, 2020 at 12:41 Comment(2)
This solution worked for me, accepted answer unfortunately didntAntipasto
Thanks alot for your solution in here, I use your method is worked for me, I just want to comment one more step, we got to reuse old ibdata1 file from C:\xampp\mysql\data. This file can not replace otherwise database table will locked, thanksWager
W
2

I had encountered the same issue, but all I had to do was close the XAMPP Control panel, go to the folder in which XAMPP is installed, find xampp-control.exe and run as administrator and then start the services.

enter image description here

Wilmoth answered 13/12, 2020 at 18:4 Comment(0)
L
2

Follow these steps:-

  1. Go into C:\xampp\mysql

  2. Rename data folder by data_old

  3. Create a new folder empty data folder

  4. Copy all files from data_old and paste them into the data folder

  5. Copy all files from the backup folder and paste them in the data folder and replace all files

  6. Copy ibdata1 files from data_old and paste and replace them in the data folder.

  7. Restart Server

Lethbridge answered 14/10, 2021 at 16:42 Comment(1)
something similar worked for me and it was the only workaround that fixed the problem. But here there is something missing, maybe you proposed to copy too many files from the corrupted folder. It didn't work for me, instead, a similar, but not identical solution proposed by Hasitha, worked for me ... just scroll down.Onstad
G
2

A simple solution

Rename the below files in the xampp\mysql\data folder:

 ib_logfile0
 ib_logfile1

Or any such logfiles to

 ib_logfile0.bak
 ib_logfile1.bak

And now start MySQL from the XAMPP control.

Geophyte answered 31/12, 2021 at 7:34 Comment(0)
H
2

Try the following solutions to fix the issue. Before performing this process, rename the data folder C:\xampp\mysql\data to the old_data. Then create a new folder named data in the SQL folder. Copy all the files and folders in the backup C:\xampp\mysql\backup folder into the data folder. In the last step, copy the ibdata1 file and the test folder from the old_data folder and put it in the data folder. Run the program now and enjoy!

Horselaugh answered 5/6, 2022 at 6:52 Comment(0)
O
2

I had the same problem.

My XAMPP control panel will start Apache, but not MySQL. The problem is in iblogfile. This happens when you are running xampp/mysql and your PC restarts without properly shutting down the InnoDB engine. Go to xampp/mysql and delete:

ib_logfile0

and

ib_logfile1

Now restart MySQL and it should work.

Obed answered 20/8, 2022 at 23:52 Comment(0)
B
2

I open and empty the file multi-master.info which exists in the data folder. This worked for me.

Bicycle answered 19/9, 2022 at 12:6 Comment(0)
V
2

Temporary Solution;

delete the aria_log_control file. You can find it on C:\xampp\mysql\data(my path is like this). Then restart MySQL.

I saw this solution on the internet but I don't remember the source.

Variform answered 30/3, 2023 at 20:22 Comment(0)
O
1

In my case in which I synced my mysql data and htdocs to dropbox, I just needed to delete the conflicted files in mysql/data folder and subfolders. The conflicted files can be identified by its names, dropbox will tell you that. It has solved the problem for me.

Ostensorium answered 11/1, 2015 at 9:15 Comment(0)
R
1

For me I quit Skype, which was occupying port 80, then Apache ran happily on port 80, than I ran Skype and it picked another port this time.

Richmal answered 28/6, 2015 at 15:57 Comment(0)
F
1

Make sure the system time is correct. Mine was set to the year 2040 somehow, correcting the date solved the problem.

Fatigued answered 26/12, 2016 at 6:11 Comment(0)
M
1

i comment this statement in mysql/bin/my.ini

'innodb_additional_mem_pool_size=2M'

and it solve my problem.

Mercury answered 20/6, 2018 at 9:5 Comment(5)
I don't have that line at allRunic
Are you on windows ? what is your xampp version ?Mercury
Yes, Win 10 with XAMPP 3.2.4Runic
did you have access to your mysql/bin/my.ini file?Mercury
gist.github.com/susanBuck/52f8a8508d94834332b1d565fb3a0e00 see this link, and check your file location that it's supposed to be in C:\xampp\mysql\bin\my.ini , find the line innodb_additional_mem_pool_size and comment it.Mercury
X
1

For me, the problem was:

I used to hibernate my PC instead of shutting down due to the scale of the project. I was lazy enough to reopen all programs.

Before trying anything else, I recommend you to do the following simple things. Otherwise, you will be messed up your MySQL server.

  1. Open your task manager and End the XAMPP process.
  2. Re-run the XAMPP application as Administrator.

If not works,

  1. Save all unsaved programs and restart the PC.
  2. Run XAMMP as administrator.

Also, make sure to check 3306 & 5040 ports. These two ports are required to run MySQL on default settings.

Check @Ryan Williams answer to find of why it's good to run XAMPP as administrator.

Xebec answered 22/10, 2019 at 5:14 Comment(0)
V
1

Delete every file from folder c:\xampp\mysql\data, except my.ini.

Voyage answered 25/3, 2020 at 14:12 Comment(1)
Sure it works but some tables does not exists after this operation. My opinion backup data folder to zip file or another path. then try this operation. After completed restore ibdata1 and ib_logfile0 and ib_logfile1 now it works and all tables restored Actions: Server = Xampp Application = Voyager admin (Laravel)Protamine
O
1

First of all, make a backup file of your database, C:\xampp\mysql\data. Copy this file and paste it somewhere in your PC.

After this, open the data file and also open the XAMPP server. Try to delete the files step by step, one by one. After deleting each file, try to run the MySQL server after deleting a single file as shown in the screenshot. Thus your databases won't delete.

If the file deletion does not work, then try to copy the same files from the backup folders and repeat this until it works... This is time taking, but this worked for me. I have solved this in 20 minutes.

Enter image description here

Overuse answered 1/9, 2020 at 16:17 Comment(1)
On Windows, presumably?Bedding
L
1

I faced the same issue. MySQL stops as soon as I turn it on.

In the logs it said:-

10:31:21 [mysql] Problem detected! 10:31:21 [mysql] Port 3306 in use by "Unable to open process"! 10:31:21 [mysql] MySQL WILL NOT start without the configured ports free!
10:31:21 [mysql] You need to uninstall/disable/reconfigure the blocking application
10:31:21 [mysql] or reconfigure MySQL and the Control Panel to listen on a different port

I stopped the running service on port 3306 wamp(in my case), and it worked fine after that. Changing the port in config settings should also work.

Lamee answered 31/10, 2021 at 19:4 Comment(0)
J
1

None of the solutions above are not working. It's working only temporarily. After a few days, we are facing the same issue again & again. I've lost all of my DBs on each and every time.

I don't know the exact solution. But, I am doing the 3 simple steps again & again.

  1. Rename the folder c:\xampp\mysql\data to c:\xampp\mysql\data_old (you can use any name).
  2. Create a new "data" folder c:\xampp\mysql\data
  3. Copy all your database folders that are in mysql\data_old to mysql\data

then Start MySQL from the XAMPP control panel.

SOLVED!: I solved it using this method:

Open shell from from control panel and start mysql with this command:

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

Open another shell from the control panel and repair the database with this command:

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

Stop mysql, close shells, and restart mysql normally.

Refer: https://mcmap.net/q/74835/-mysqld-exe-table-39-mysql-db-39-is-marked-as-crashed-and-should-be-repaired

Jodeejodhpur answered 29/4, 2022 at 6:27 Comment(2)
Some of this has been wholesale plagiarised from this 2019 answer.Bedding
Yes, #58386740 & #56848304 I tried different method in this thread. none of the solutions not worked. that's why i added it here & also added Referer link.Jodeejodhpur
S
1

enter image description here In my case Mysql could not start due to the below issue (mysql_error.txt):

2024-03-27 19:42:10 0 [ERROR] mysqld.exe: Aria recovery failed. Please run aria_chk -r on all Aria tables and delete all aria_log.######## files 2024-03-27 19:42:10 0 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.

Solution:

  1. Open Shell from xampp control panel.
  2. run aria_chk -r
  3. Del all aria_log.######## files

After following the above steps: enter image description here

Semiaquatic answered 27/3, 2024 at 14:27 Comment(0)
A
0

Menu ConfigApacheOpen httpd.conf. Search for Listen or 80, and update the listen port to 8081. Save and restart the server.

Oh and shutdown Skype if you have it.

Appraise answered 2/8, 2013 at 17:56 Comment(1)
Yeah, that fixed it. I swear I reinstalled before posting that, but I guess not. Thanks :)Sheenasheeny
B
0

For this, you need to click on the x option under Modules Services and make MYSQL services installed. Then start the services. Here you go.

Bernardabernardi answered 3/2, 2015 at 14:38 Comment(0)
S
0

If the crash message is "mysql.exe has stopped working". Just run xampp-control.exe as administrator will solve your problem instantly.

Sherard answered 5/7, 2017 at 7:36 Comment(0)
I
0

If any of the things above do not work, make a back of Xampp directory and reinstall Xampp. That surely works!

Indiscreet answered 10/8, 2017 at 16:47 Comment(0)
R
0

Rename below files from mysql/data ib_logfile0 ib_logfile1 ibdata1

my.cnf innodb_buffer_pool_size to 200M as per your ram innodb_log_buffer_size to 32M

Restart your apache server

Rotator answered 12/12, 2018 at 4:55 Comment(0)
A
0

I solved! deactivate UAC with msconfig before to install xampp

enter image description here

Artemisa answered 13/7, 2019 at 17:55 Comment(0)
I
0

That's the more precise answer and worked for me!!!! ! 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. as mentioned above by Ryan Williams.

Iroquoian answered 25/7, 2019 at 14:59 Comment(0)
P
0

Go to task manager And search mysqld and right click and select END TASK and refresh XAMPP

Packsaddle answered 7/9, 2019 at 6:5 Comment(0)
M
0

If you are getting this type of error then

Create a backup of your MySQL folder from C:\xampp\mysql. Then go to C:\xampp\mysql\backup. Copy all the files and paste them into C:\xampp\mysql\data.

Then from your old backup folder, look for the ibdata1 file you can find it in C:\xampp\mysql\data. Copy this file and paste in into C:\xampp\mysql\data.

Now restart XAMPP, and it should work.

Mump answered 29/5, 2020 at 6:43 Comment(0)
A
0

There are a number of things I've tried. This is the second time this has happened to me. The first time, I've to reinstall my XAMPP. And on the third day, MySQL crashed again.

I've tried everything I found on the Internet. Like, innodb_flush_method=normal in my.ini file and deleting ibdata1, ib_logfile1, ib_logfile0 files, and others, but none of these works.

So later I tried to run XAMPP with administrator privilege and install Apache and MySQL as a service as it was instructed on XAMPP control panel itself. After starting MySQL, I read error-log again and from there I came to know that one of my databases is responsible for this. That database file won't let MySQL start. So I deleted everything in the data folder and then in cmd I navigated to the C:/xampp/mysql/bin path and ran these commands:

mysqld --initialize

mysql_install_db

and MySQL started running again. But my databases and data are lost.

Autophyte answered 19/7, 2020 at 11:26 Comment(0)
E
0

If none of the solutions listed here didn't work for you, just like me, then

  1. Go to your Task Manager
  2. Go to the Services tab.
  3. Find Service named "MySQL80".
  4. Right-click on it and select "stop".
  5. Go back to XAMPP control panel and start the MySQL service.

It worked for me.

Eusporangiate answered 9/10, 2020 at 4:54 Comment(2)
On Windows, presumably?Bedding
That's correct.Eusporangiate
P
0

If none of the deletion of files work then probably your MySQL service is not running. Go to services.msc and start the MySQL service.

Ploss answered 7/11, 2020 at 8:16 Comment(1)
On Windows, presumably?Bedding
D
0

enter image description hereI also had this problem when i get this error , go xampp->mysql->data then delete all other files without folder , do not delete folders , then run xampp and start mysql

Deathwatch answered 4/1, 2021 at 4:55 Comment(1)
I did this. MySQL server is working. But all the tables from all the databases now vanish.Moist
E
0

If you do not need data in the corrupt table, you can drop it by first discarding the tablespace:

ALTER TABLE sakila.actor DISCARD TABLESPACE;

after that you can drop the table itself:

DROP TABLE sakila.actor;

In case the first step is not working, first replace actor.ibd file with a copy from an empty table with the same structure.

Source

Elsi answered 17/8, 2021 at 7:13 Comment(0)
P
0

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

  1. stop all running XAMPP services (Apache, MySQL, etc.)

  2. rename the xampp folder to xampp-old

  3. install a fresh XAMPP

  4. Restore databases by copying these three files (ibdata1, ib_logfile0, and ib_logfile1), and your database folders you created from xampp-old from this path:

    xampp-old\mysql\data
    

    to

    xampp\mysql\data
    

    and accept to replace files

  5. Restore the coded files by transferring xampp-old\htdocs to xampp\htdocs

    Now start XAMPP. It will work with all of your data.

Note: if you need to edit the Apache or MySQL .ini files, do this again

Politesse answered 7/6, 2022 at 5:35 Comment(0)
T
0

Step 01: If you have an error with starting XAMPP MySQL, follow these steps to easily solve this problem.

Enter image description here

Step 02: Stop the Server and go to Config.

Enter image description here

Step 03: Open this my.ini file.

Enter image description here

Step 04: Find these two port numbers in your notepad text.

Enter image description here

Step 05: Change these two port numbers, 33063308 or any other number.

Enter image description here

After saving the text file, using Ctrl + S

Step 07: Go to your XAMPP installation folder and open the XAMPP folder.

Step 08: Find the phpMyAdmin folder.

Enter image description here

Step 09: Open the phpMyAdmin folder and find the config.inc.php file.

Enter image description here

Step 10: Change the port number here that previous you changed in Step 05. (Like 3008) and Save this text file.

Enter image description here

Step 11: After closing all files and going to your XAMPP server.

Step 12: Start the MySQL server again.

Enter image description here

Step 13: Open your web browser and type in the URL → localhost

Step 14: Go to PhpMyAdmin

Enter image description here

Step 15: phpMyAdmin is working properly now.

Enter image description here

If you have any error in starting the Apache server,

Step 01: Stop the server, and open the configuration file.

Enter image description here

Enter image description here

Step 02: Find this Listen number in your text file.

Enter image description here

Step 03: Change that 80 to 8000 or any other value. And save the text file.

Enter image description here

Step 04: After saving the text file, open your XAMPP server and Start the Apache server again.

Enter image description here

Step 05: After opening your web browser.

Step 06: Type localhost:8000

Enter image description here

Step 07: Now you can open your phpMyAdmin.

Enter image description here

Note: After changing the Apache port number, you must add in to that after the localhost: in your URL.

Talaria answered 24/6, 2022 at 21:49 Comment(1)
This doesn't work. Same problem 😂Pandanus
C
0

Go to task manager and end your running MySQL task and restart your MySQL in XAMPP

Cataract answered 26/8, 2022 at 22:2 Comment(2)
On Windows, presumably?Bedding
yeah, on WindowsCataract
K
0

This happened when you already use the 3306 port. Just change the server port and it would be fixed.

Knife answered 20/10, 2022 at 13:17 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Phew
S
0

Open the configuration file of MySQL in XAMPP and change the port number to 3307. It worked for me :)

Sturdivant answered 3/11, 2022 at 5:6 Comment(0)
C
0

first go to config from control panel

then edit the port of mysql to 8111

then go to : my.ini file at C:\xampp\mysql\bin

and make the port from 3306 to 8111 then save

and go to control panel and stop the apache
then try to turn it on again with my sql it will work with me

Cassity answered 31/1, 2023 at 16:51 Comment(1)
Please add some explanation to your answer such that others can learn from it. What makes you think that the given error message is related to ports?Migraine
S
0

If you have this issue and you are using XAMPP then before deleting/moving/renaming any file or folder, just open Task Manager and search for XAMPP and if you find any rows just end this task.

enter image description here

enter image description here

Now open XAMPP again and try to start sql.

Sherilyn answered 8/6, 2023 at 15:39 Comment(0)
A
0

I use this command thought the shell of xampp:

mysqld --console --skip-grant-tables --skip-external-locking
Aphra answered 12/11, 2023 at 11:1 Comment(1)
Please add some explanation to your answer such that others can learn from itMigraine
M
0

Go to mysql/data then rename(preferable) or delete mysql.pid.. then start mysql in xampp panel... works like charm

Michaelson answered 8/12, 2023 at 14:57 Comment(0)
I
0

I had the same problem for some time now and while most of the suggestions in this answer worked me I had to re-install xampp and copy and paste the files and table folders from xampp\mysql\data to the new installation of xampp.

enter image description here

Ran into the same problem almost every week so I opened xampp and kept getting the above error so I started deleting files leaving the ones that I believed were the most important ones enter image description here

Well guess what I didn't even have to restart xampp it just started working I guess those two files were the only important ones and all the others were causing this problem

enter image description here

Isidraisidro answered 25/1, 2024 at 4:5 Comment(0)
O
0

To answer to this error

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

In windows

Just simply open Task manager and open Services section and then start again the MYSQL server it'll work perfectly no need to do anything else.

This simple trick worked for me, I have done it more than 20 times.

enter image description here

Ovular answered 29/1, 2024 at 16:5 Comment(2)
this is not a permanent solution.Display
Yes, But most of the time it's working properly. Instead of doing changes in files, this solution is easy if it works.Ovular
S
-1

I fixed it by reinstalling XAMPP.

If you don't want to go through all the technical stuff that the other proposes.

Back up the htdocs folder and then uninstall XAMPP. It will ask you if you want to retain the htdocs folder. Opt out.

Completely uninstall, and remove the remains.

Then install again. Copy back your backed-up htdocs folder.

You're done.

Simmie answered 22/10, 2020 at 20:47 Comment(2)
The MySQL database was corrupted. Perhaps files were copied around. Somehow two different tables ended up with the same tablespace id and that is not possible during normal MySQL operation. By removing XAMPP you removed MySQL and then you reinstalled it, which fixed the corruption. It would be possible to remove the MySQL data directory and re-initialize it, but uninstalling and reinstalling did the same.Purvey
I think mysql database will be removed in this case. Someone let me know.Reni
R
-1

Solve it in 10 seconds:

  1. Go to the "mysql" folder inside your "xampp" folder
  2. rename the data folder as "data-old"
  3. create a new folder name, as "data"
  4. copy all the contents of the backup folder into new "data" folder...

You are good to go.

Resident answered 5/7, 2022 at 12:56 Comment(3)
this is not working votes downBellringer
Please add some explanation to your answer such that others can learn from it. Why should copying all files resolve the problem?Migraine
The OP has left the building: "Last seen more than 1 year ago". Perhaps somebody else can chime in, for example, with the (literal) folder names?Bedding
C
-1

You are getting this error, because your SQL port 3306 is busy (another app is using it).

Stop the process of 3306 (by closing that app end process).

But how can we find that?

Download the TCPView of microsoft. Open the app and search for "sql". You will see the sql is running and using 3306 port. That is why the XAMPP's MySQL is unable to run...

Just end the process. The MySQL and you are good to go. Start the MySQL of XAMPP and done.

Canso answered 21/7, 2022 at 17:50 Comment(1)
What do you mean by "the sql"? Microsoft's SQL Server?Bedding
U
-1

This PowerShell script automated the solution for you:

Rename-Item -Path "./data" -NewName "./data_old"

# Create new data directory
Copy-Item -Path "./backup" -Destination "./data" -Recurse
Remove-Item "./data/test" -Recurse
$dbPaths = Get-ChildItem -Path "./data_old" -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory
Copy-Item -Path $dbPaths.FullName -Destination "./data" -Recurse
Copy-Item -Path "./data_old/ibdata1" -Destination "./data/ibdata1"

# Notify user
Write-Host "Finished repairing MySQL data"
Write-Host "Previous data is located at ./data_old"

https://gist.github.com/josemmo/24e35f2b4984a4370ce2c164f5956437

Unkempt answered 2/3, 2023 at 12:54 Comment(0)
I
-1

I wrote this answer as reminder for me too.

Blocked Port: Ensure that port 3306 (MySQL's default port) is not being used by another application. netstat -ano | findstr :3306 in the command prompt (run as administrator) to check for any conflicts.

In my case, i have 2 running on 3306 enter image description here


to solve this: open taskmanager and search for mysqld

enter image description here

I have 2 running in the background. these the reaseon why i cant run MySQL from xampp. since its already running from other resources.

Solutions:

  • stopping the process directly from the Task Manager and then start MySQL from XAMPP.
  • end task in the taskmanager
  • start from xampp

solved.

Illuminati answered 23/1, 2024 at 3:18 Comment(1)
What do you mean by "blocked port"? How does this answer related to the original problem, where a problem with the InnoDB files was reported?Migraine
M
-3

Find my.ini file inside xampp/mysql/bin, then find [mysqld] section and add this line after error log:

innodb_force_recovery = 6

Then start MYSQL, once it starts, you can remove the code from it and save it back to normal.

Morly answered 26/3, 2024 at 14:57 Comment(2)
Please don't duplicate existing answers - this was already suggested in https://mcmap.net/q/73618/-how-can-i-solve-quot-error-mysql-shutdown-unexpectedly-quot-closedMigraine
i havent seen this anywhere .. and it help me to solve the issue . so I thought it might help someone else .. that's why I posted ..Morly

© 2022 - 2025 — McMap. All rights reserved.