558

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?

3
  • I just deleted info files in my xampp\mysql\data\ folder and it works for me. Commented Jul 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? Commented Nov 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 :-/ Commented Mar 28 at 6:18

89 Answers 89

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

  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.

45
  • 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
    Commented Jul 9, 2020 at 7:42
  • 70
    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
    Commented Aug 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
    Commented Sep 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
    Commented Sep 13, 2020 at 17:46
  • 6
    No use, still keep repeating the same issue after few days. Commented Apr 29, 2022 at 5:39
249

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.

18
  • 53
    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. Commented Sep 3, 2013 at 12:13
  • 25
    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
    Commented Oct 12, 2013 at 10:50
  • 18
    I also had to delete ib_logfile0 and ib_logfile1 to get it to work Commented Jun 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
    Commented Mar 14, 2017 at 4:16
  • 35
    The most upvoted unexplained reckless thing you can do Commented Jan 14, 2018 at 10:36
147

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.

23
  • 4
    Still the same error occur
    – Merbin Joe
    Commented Mar 18, 2022 at 4:43
  • 1
    Worked for me, running xampp 7.4.16
    – CapelliC
    Commented Mar 20, 2022 at 17:48
  • 1
    @Mustafasabir I still have all the data after doing this.
    – Dexter
    Commented Jun 22, 2022 at 10:33
  • 3
    Thanks, worked for me in xammp v8.1.6 . Please summarize it a little :)
    – Saeid Z
    Commented Jul 12, 2022 at 15:55
  • 3
    Worked for me in xampp v3.3.0. Thank you so much Commented Jul 19, 2022 at 9:44
94

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.

0
79

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.

10
  • 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
    Commented Sep 8, 2021 at 1:55
  • 1
    It works for me. No database lost. One of the best answer. Commented Nov 9, 2022 at 7:07
  • 1
    Only this post has solved my Mysql problem. Best one here. Thanks so much, man.
    – mowx
    Commented Jan 5, 2023 at 12:47
  • 2
    Your welcome @mowx . We rise by lifting other. Commented Jan 5, 2023 at 15:01
  • 2
    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
    Commented Nov 24, 2023 at 14:24
48
  1. Go to mysql/data/
  2. Delete all random files (except the actual database folders)
  3. Restart Apache and MySQL.

It should fix it.

5
  • 25
    It deleted all my data. There was a lot of data.
    – Paras
    Commented Mar 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.
    Commented Apr 25, 2018 at 0:27
  • No Luck... Still having the same issue. Commented Feb 28, 2022 at 5:28
  • 9
    Dont TRY this! 100% deletes all your databases, Commented Jul 12, 2022 at 9:47
  • 1
    Why is this answer upvoted? Commented Dec 9, 2022 at 9:16
42

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.

6
  • 4
    This is the only (and simplest) answer that worked for me.
    – smolo
    Commented Oct 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
    Commented Apr 8, 2023 at 6:36
  • works for me too Commented Dec 1, 2023 at 14:34
  • 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! Commented Dec 22, 2023 at 15:10
  • @SkSuraj Try it. It will work.
    – Yasir Ijaz
    Commented Dec 24, 2023 at 14:57
38

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

4
  • 3
    It is working for me. I have faced this problem second time. Commented May 11, 2022 at 7:18
  • 1
    this might be the answer i'm looking for. thanks! Commented Mar 10 at 5:17
  • 1
    It is a working solution
    – Toton
    Commented Jul 31 at 5:58
  • best answer, works for me on windows 11 in 2024
    – Mohit Rane
    Commented Sep 8 at 10:01
38

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

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 exist
    – C-Bizz
    Commented Oct 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. Commented Oct 20, 2021 at 5:30
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.

8
  • 1
    This should be accepted as correct answer. If you remove ibdata1, there will be tons of orphaned tables.
    – sean
    Commented Mar 3, 2015 at 20:05
  • Thanks, you fixed my problem after trying a ton of different things. Commented Dec 23, 2015 at 21:42
  • also fixed issue for me
    – Gaz Smith
    Commented Apr 29, 2019 at 8:36
  • Nice explannation :D Thank you.
    – logbasex
    Commented Jun 4, 2020 at 3:21
  • The 'Restore previous versions' option only works if you regularly create Restore Points in Windows. :(
    – nockieboy
    Commented Jun 9, 2020 at 9:04
20

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.

4
  • Thanks, @haider. be careful while doing the above steps. Commented Mar 12, 2022 at 13:28
  • 1
    Thanks I am exploring from last 2 hours, you save my time. Commented Mar 28, 2022 at 17:43
  • does not work for me Commented Oct 8, 2022 at 8:55
  • May I know what exactly you are facing @MuhammadSarmadMahmoodMalik Commented Apr 12 at 16:52
18

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

1
  • 2024 - worked for me Commented Apr 7 at 15:25
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

4
  • 2
    Changing port worked for me and no other method worked Commented Dec 18, 2020 at 13:09
  • 3
    This is the best answer. Everyone should follow this
    – Al Mahdi
    Commented Mar 5, 2022 at 14:22
  • 1
    It is ok now after changing port. thanks. Commented Feb 17, 2023 at 6:15
  • 1
    Thank you so much, worked even i didnt followed A and B step. Commented Mar 21, 2023 at 6:35
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.

0
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
3
  • 7
    Read about what you are doing, before you do it: dev.mysql.com/doc/refman/5.0/en/forcing-innodb-recovery.html Commented Sep 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
    Commented Aug 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
    Commented Sep 13, 2020 at 5:42
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

3
  • Thanks man worked like a charm for me. :) Commented Dec 16, 2020 at 6:46
  • Thanks this solve the issue but we need to keep old ibdata file, else we will lose the data Commented Aug 12, 2021 at 11:27
  • 1
    Never do that. I have lost my data.
    – Shiva
    Commented Aug 23, 2021 at 5:34
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
1
  • Don't do it. From official manual "Directly editing or moving the redo logs can cause corruption, and should never normally be attempted."
    – danblack
    Commented Jul 29 at 23:34
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
3
  • This is the only proposed workaround that worked for me without losing the last improvements of my DB data model. Thank you.
    – fede72bari
    Commented Aug 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. Commented Dec 4, 2023 at 20:01
  • You are right. And this solution worked for me. Don't order to take backup of data folder first. Commented Aug 3 at 7:16
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.
0
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

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. Commented May 28, 2023 at 8:46
9
  1. Copy all files from folder xampp/mysql/backup/ and then paste them into folder /xampp/mysql/data/
  2. Restart MySQL.
3
  • Nothing worked on this topic but your method worked very well. Thanks
    – Codecopath
    Commented Aug 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. Commented Oct 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. Commented Sep 29, 2023 at 4:26
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.

3
  • 1
    Thank you, none of the other options worked for me, this one did. Very grateful Commented Jan 27, 2020 at 19:58
  • @user3808307 I'm glad it helped you :)
    – Sobhan
    Commented Jan 28, 2020 at 6:28
  • thank you so much! this was really simple to do and it worked :)
    – Aditi
    Commented Feb 25, 2021 at 6:35
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.

3
  • This is not a valid answer!
    – abhiarora
    Commented Jan 11, 2017 at 15:37
  • Not valid answer Commented Aug 1, 2019 at 15:10
  • I can't find the MySql service in my system. Commented Apr 28, 2022 at 11:46
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.
2
  • Amazing .Your answer woking fine .Thank you so much
    – Ganesan J
    Commented Jan 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
    Commented Jan 3, 2022 at 10:00
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
0
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

0
6

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

Enter image description here

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

5

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

5

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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.