Related
When I open XAMPP and click start MySQL button and it gives me an error.
I had started it just before, but now it isn't working.
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?
IMPORTANT: do NOT delete ibdata1 file. You could destroy all your databases.
Instead, first try using the MySQL backup folder which is included with XAMPP. So do next steps:
Rename folder mysql/data to mysql/data_old
Make a copy of mysql/backup folder and name it as mysql/data
Copy all your database folders from mysql/data_old into mysql/data (except mysql, performance_schema, and phpmyadmin folders)
Copy mysql/data_old/ibdata1 file into mysql/data folder
Start MySQL from XAMPP control panel
And, voilà!
EDIT (January 7th 2023)
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.
IMPORTANT Deleting this file may render any existing MySQL data unusable. Use with caution
Hey I just did this and it worked:
exit Xampp server
go to your C:\xampp\mysql\data directory
delete the ibdata1 file
restart xampp server
It should work
Jun 2022
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
XAMPP Fixed
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 with no unwanted software or issues, and I got this unexpected shutdown again after a long time. I came to this question, hoping someone would tell me actually what was going on instead of fixing these issues. But unfortunately, I could not find it.
Just to clarify, my new issue is not with
port
unexpected shutdown
windows stuck
unwanted software
virus or malware.
One day I turned on xampp, and it stops working.
Method 1 (22 Dec 2021)
Stop MySQL.
Go to the C:/xampp/mysql directory and copy the data folder and keep it somewhere else (probably in another drive) as a backup.
Go to your original data folder (C:/xampp/mysql) and sort the files by 'Type.'
Select the files that have the type INFO File and delete them (screenshot below).
Start MySQL. It should work now.
Method 1 Screenshot
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.
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.
Let me know if it works for you.
If the answers mentioned above are not working, you can try deleting all the files in data, except for the folder
Goto:
C:\xampp\mysql\data
After that:
Goto: C:\xampp\mysql\bin
then open with notepad my.ini
, Its look like this.
Then delete or put into comment the port 3306 and change it to 8111 then run xamp with administrator and its work well.
Go to mysql/data/
Delete all random files (except the actual database folders)
Restart Apache and MySQL.
It should fix it.
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).
IMPORTATN NOTE :- Please do not replace the existing files while pasting(click skip these files)
Step 5. Finally copy the ibdata1 file from mysql\data_bkp and replace it inside mysql\data folder.
Step 6. Start MySQL from XAMPP control panel.
And, Its DONE . No databases lost, no ports changed, no run as administrator, no force recovery, no kill mysqld process, no restoring from previous versions, no more errors.
Just follow two steps
go to xampp\mysql\backup
copy everything from backup folder
go to xampp\mysql\data
paste everything in data folder copied from backup folder
Thats all.
Also follow the video description to fix without losing any data:
https://www.youtube.com/watch?v=hB1wshpP3Jc
Or follow the article description to fix without losing any data:
https://webjourney.dev/error-mysql-shutdown-unexpectedly-solve-without-loosing-any-data-webjourney
UPDATE APRIL (2022)
Rename folder mysql/data to mysql/data_old
Make a copy of mysql/backup folder and name it as mysql/data
Copy all your database folders and mysql folder from mysql/data_old into mysql/data
Copy mysql/data_old/ibdata1 file into mysql/data folder
Start MySQL from XAMPP control panel
REFERENCE
https://www.youtube.com/watch?v=ipMedkjMupw&ab_channel=GeekyScript
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.
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, these steps fix the problem:
Make sure mysql and xampp is shut down completely.
Go to your directory where mysql is installed, mine is: C:\xampp\mysql\data
You should see a folder with the name of a database that you created. mine was test_database.
Create a new folder somewhere else called C:\xampp\mysql\data\mysql\backuptablespace
Drag and drop (don't delete) the offending database table folder to the backup directory.
Try to start mysql again. For me it started right up in 1 second as expected.
If it doesn't work, put the file back where you started and you'll be back where you started.
If you don't want to delete the database and don't have backups:
If you don't have backups of table data and mysql won't start because something is corrupted you'll have to use the process of elimination to guess-and-check your way to exactly what you did that corrupted it. Follow these steps:
Make a clone of the entire C:\xampp\ and store it somewhere safe so you can get back to where you started.
Use a "binary search" approach to try to locate the corrupted item in the mysql database. It could be a file, or a table, or a database, or a user or anything.
Delete the entire database and see if that allows mysql to start. If it does, then put back the database and try removing some of the tables. If it doesn't, then try yanking out something else until it does start.
Try removing these files from C:\xampp\mysql\data\mysql:
db.frm
db.MRD
db.MYI
db.opt
user.frm
user.MYD
user.MYI
When you get mysql to start, try putting things back until you find the one thing that you add which prevents it from starting. One bonus for this is you learn how mysql works under the hood.
Nuclear option:
Something you did screwed up the mysql server. An uninstall and reinstall of XAMPP should undo the corruption.
Add the following line below the [mysqld] section in the mysql config file (my.ini) and restart the apache web server and the mysql service afterwards.
[mysqld]
innodb_force_recovery = 4
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
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
Never delete this file (ibdata1) because all your data will be deleted!!!
I suggest three ways :
A:
1- Exit from XAMPP control panel.
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- Reastart your system.
B:
1- Stop all sql services.
2- Next, start all sql services again.
C:
1- Open XAMPP control panel
2- Click on Config button, in front of mysql, click on my.ini
3- change client port and server port.
I have tried all the above answers but it didn't work for me. So finally I tried the below approach and it works 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.
I also faced this issue and this is how I solved.
1. Make sure xampp is not under sub-directory. For example, it should be C:\xampp
2. You might need to run as administrator in running the application.
Hope this will work!
in my case i did following steps and it worked:
In Xampp control panel click on "Services" button from the right side toolbar
Then find "MySQL" from the services List
Click on it and from the left side of the panel click on "stop"
Turn back in Xampp control panel and click on start.
move xampp/mysql/backup files into xampp/mysql/data
RUN XAMPP as Administrator(make sure mysql is installed you can see a green tick if is installed)
Hope it helps!
Simple solution
Open shell from Xampp Control Panel
mysqld --console --skip-grant-tables --skip-external-locking
Then again open an other shell and run
mysqlcheck -r --databases mysql --use-frm
Now close both shells and restart the xampp.
I have resolved the problem by ending the task for mysqlid on Task Manager.
Here is the way you can solve this problem:
Go to C:\xampp\mysql\data
You will see a folder named as mysql/data
Rename that folder from mysql/data to something else like mysql/data_not_useful any name that you want to give.
Create a new folder named as mysql/data.
Copy all the files of the mysql/backup and paste in mysql/data.
Now go to mysql/data_not_useful and copy the file ibdata1 from there.
Then paste it in mysql/data (You have to replace the file).
Restart your xampp server.
Now run your mysql server.
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.
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.
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.
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.
Had the same issue.
STAEP 1
backup folder xampp/mysql/data (saved it as `xampp/mysql/_old_data`).
STAEP 2
Go to xampp/mysql/data and deleted all the files but not folders! With databases.
STAEP 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.
STAEP 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.
Xampp stop Instantly after start.
copy all files and folder from C:\xampp\mysql\backup and paste into
C:\xampp\mysql\data.
Go to xampp/mysql/data
Rename folder from data to data_backup
Create new folder data
Copy files from backup to data
delete ibdata1 from data folder
Copy ibdata1 from data_backup folder to data folder
Copy your all database from data_backup to data folder
Restart xampp. It will start working
Copy all files from xampp/mysql/backup/ then paste into /xampp/mysql/data/
Restart mysql.
0.cntr+alt+delet
1.end task mysqld
2.Restart mysql.
mySQL won't start and it throws up this in the log: http://pastebin.com/rTvMiQFV.
This seems quite common on here, but none of the solutions I've read have worked.
The only difference I can see between my problem and everyone else's is that mine has only just started happening, I was using it just fine before and it stopped at random after I restarted my computer.
It's happened before, and after trying everything I ended up backing up my databases and reinstalling the whole of xampp, but I don't really want to do that.
Any suggestions?
Did you try doing the suggested steps:
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.
When I open XAMPP and click start MySQL button and it gives me an error.
I had started it just before, but now it isn't working.
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?
IMPORTANT: do NOT delete ibdata1 file. You could destroy all your databases.
Instead, first try using the MySQL backup folder which is included with XAMPP. So do next steps:
Rename folder mysql/data to mysql/data_old
Make a copy of mysql/backup folder and name it as mysql/data
Copy all your database folders from mysql/data_old into mysql/data (except mysql, performance_schema, and phpmyadmin folders)
Copy mysql/data_old/ibdata1 file into mysql/data folder
Start MySQL from XAMPP control panel
And, voilà!
EDIT (January 7th 2023)
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.
IMPORTANT Deleting this file may render any existing MySQL data unusable. Use with caution
Hey I just did this and it worked:
exit Xampp server
go to your C:\xampp\mysql\data directory
delete the ibdata1 file
restart xampp server
It should work
Jun 2022
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
XAMPP Fixed
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 with no unwanted software or issues, and I got this unexpected shutdown again after a long time. I came to this question, hoping someone would tell me actually what was going on instead of fixing these issues. But unfortunately, I could not find it.
Just to clarify, my new issue is not with
port
unexpected shutdown
windows stuck
unwanted software
virus or malware.
One day I turned on xampp, and it stops working.
Method 1 (22 Dec 2021)
Stop MySQL.
Go to the C:/xampp/mysql directory and copy the data folder and keep it somewhere else (probably in another drive) as a backup.
Go to your original data folder (C:/xampp/mysql) and sort the files by 'Type.'
Select the files that have the type INFO File and delete them (screenshot below).
Start MySQL. It should work now.
Method 1 Screenshot
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.
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.
Let me know if it works for you.
If the answers mentioned above are not working, you can try deleting all the files in data, except for the folder
Goto:
C:\xampp\mysql\data
After that:
Goto: C:\xampp\mysql\bin
then open with notepad my.ini
, Its look like this.
Then delete or put into comment the port 3306 and change it to 8111 then run xamp with administrator and its work well.
Go to mysql/data/
Delete all random files (except the actual database folders)
Restart Apache and MySQL.
It should fix it.
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).
IMPORTATN NOTE :- Please do not replace the existing files while pasting(click skip these files)
Step 5. Finally copy the ibdata1 file from mysql\data_bkp and replace it inside mysql\data folder.
Step 6. Start MySQL from XAMPP control panel.
And, Its DONE . No databases lost, no ports changed, no run as administrator, no force recovery, no kill mysqld process, no restoring from previous versions, no more errors.
Just follow two steps
go to xampp\mysql\backup
copy everything from backup folder
go to xampp\mysql\data
paste everything in data folder copied from backup folder
Thats all.
Also follow the video description to fix without losing any data:
https://www.youtube.com/watch?v=hB1wshpP3Jc
Or follow the article description to fix without losing any data:
https://webjourney.dev/error-mysql-shutdown-unexpectedly-solve-without-loosing-any-data-webjourney
UPDATE APRIL (2022)
Rename folder mysql/data to mysql/data_old
Make a copy of mysql/backup folder and name it as mysql/data
Copy all your database folders and mysql folder from mysql/data_old into mysql/data
Copy mysql/data_old/ibdata1 file into mysql/data folder
Start MySQL from XAMPP control panel
REFERENCE
https://www.youtube.com/watch?v=ipMedkjMupw&ab_channel=GeekyScript
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.
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, these steps fix the problem:
Make sure mysql and xampp is shut down completely.
Go to your directory where mysql is installed, mine is: C:\xampp\mysql\data
You should see a folder with the name of a database that you created. mine was test_database.
Create a new folder somewhere else called C:\xampp\mysql\data\mysql\backuptablespace
Drag and drop (don't delete) the offending database table folder to the backup directory.
Try to start mysql again. For me it started right up in 1 second as expected.
If it doesn't work, put the file back where you started and you'll be back where you started.
If you don't want to delete the database and don't have backups:
If you don't have backups of table data and mysql won't start because something is corrupted you'll have to use the process of elimination to guess-and-check your way to exactly what you did that corrupted it. Follow these steps:
Make a clone of the entire C:\xampp\ and store it somewhere safe so you can get back to where you started.
Use a "binary search" approach to try to locate the corrupted item in the mysql database. It could be a file, or a table, or a database, or a user or anything.
Delete the entire database and see if that allows mysql to start. If it does, then put back the database and try removing some of the tables. If it doesn't, then try yanking out something else until it does start.
Try removing these files from C:\xampp\mysql\data\mysql:
db.frm
db.MRD
db.MYI
db.opt
user.frm
user.MYD
user.MYI
When you get mysql to start, try putting things back until you find the one thing that you add which prevents it from starting. One bonus for this is you learn how mysql works under the hood.
Nuclear option:
Something you did screwed up the mysql server. An uninstall and reinstall of XAMPP should undo the corruption.
Add the following line below the [mysqld] section in the mysql config file (my.ini) and restart the apache web server and the mysql service afterwards.
[mysqld]
innodb_force_recovery = 4
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
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
Never delete this file (ibdata1) because all your data will be deleted!!!
I suggest three ways :
A:
1- Exit from XAMPP control panel.
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- Reastart your system.
B:
1- Stop all sql services.
2- Next, start all sql services again.
C:
1- Open XAMPP control panel
2- Click on Config button, in front of mysql, click on my.ini
3- change client port and server port.
I have tried all the above answers but it didn't work for me. So finally I tried the below approach and it works 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.
I also faced this issue and this is how I solved.
1. Make sure xampp is not under sub-directory. For example, it should be C:\xampp
2. You might need to run as administrator in running the application.
Hope this will work!
Simple solution
Open shell from Xampp Control Panel
mysqld --console --skip-grant-tables --skip-external-locking
Then again open an other shell and run
mysqlcheck -r --databases mysql --use-frm
Now close both shells and restart the xampp.
in my case i did following steps and it worked:
In Xampp control panel click on "Services" button from the right side toolbar
Then find "MySQL" from the services List
Click on it and from the left side of the panel click on "stop"
Turn back in Xampp control panel and click on start.
move xampp/mysql/backup files into xampp/mysql/data
RUN XAMPP as Administrator(make sure mysql is installed you can see a green tick if is installed)
Hope it helps!
I have resolved the problem by ending the task for mysqlid on Task Manager.
Here is the way you can solve this problem:
Go to C:\xampp\mysql\data
You will see a folder named as mysql/data
Rename that folder from mysql/data to something else like mysql/data_not_useful any name that you want to give.
Create a new folder named as mysql/data.
Copy all the files of the mysql/backup and paste in mysql/data.
Now go to mysql/data_not_useful and copy the file ibdata1 from there.
Then paste it in mysql/data (You have to replace the file).
Restart your xampp server.
Now run your mysql server.
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.
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.
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.
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.
Had the same issue.
STAEP 1
backup folder xampp/mysql/data (saved it as `xampp/mysql/_old_data`).
STAEP 2
Go to xampp/mysql/data and deleted all the files but not folders! With databases.
STAEP 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.
STAEP 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.
Xampp stop Instantly after start.
copy all files and folder from C:\xampp\mysql\backup and paste into
C:\xampp\mysql\data.
Go to xampp/mysql/data
Rename folder from data to data_backup
Create new folder data
Copy files from backup to data
delete ibdata1 from data folder
Copy ibdata1 from data_backup folder to data folder
Copy your all database from data_backup to data folder
Restart xampp. It will start working
Copy all files from xampp/mysql/backup/ then paste into /xampp/mysql/data/
Restart mysql.
0.cntr+alt+delet
1.end task mysqld
2.Restart mysql.
I installed xampp in windows XP. I am able to start apache and tomcat. But when I start mysql, it gets started but stops after five seconds.
So, I am not able to work with PHPMyAdmin.
I checked the mysql_error file inside xampp/mysql/bin and the following was present.
120320 11:48:44 [Note] Plugin 'FEDERATED' is disabled.
120320 11:48:44 InnoDB: The InnoDB memory heap is disabled
120320 11:48:44 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120320 11:48:44 InnoDB: Compressed tables use zlib 1.2.3
120320 11:48:45 InnoDB: Initializing buffer pool, size = 16.0M
120320 11:48:45 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file C:\xampp\mysql\data\ibdata1 did not exist:
InnoDB: a new database to be created!
120320 11:48:45 InnoDB: Setting file C:\xampp\mysql\data\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
120320 11:48:45 InnoDB: Log file C:\xampp\mysql\data\ib_logfile0 did not exist: new to be created
InnoDB: Setting log file C:\xampp\mysql\data\ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
120320 11:48:45 InnoDB: Log file C:\xampp\mysql\data\ib_logfile1 did not exist: new to be created
InnoDB: Setting log file C:\xampp\mysql\data\ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
120320 11:48:48 InnoDB: Waiting for the background threads to start
120320 11:48:49 InnoDB: 1.1.8 started; log sequence number 0
120320 11:48:52 [Note] Event Scheduler: Loaded 0 events
120320 11:48:52 [Note] mysql\bin\mysqld.exe: ready for connections.
Version: '5.5.16' socket: '' port: 3306 MySQL Community Server (GPL)
I am using xampp 1.7.7
please help...
This worked for me,
quit the XAMPP
cut the All files in C:\xampp\mysql\backup
paste and replace files in C:\xampp\mysql\data
run as administrator the XAMPP
i had the same problem and i have found a temporary solution by going to the installation folder
xampp->mysql->bin-> mysqld.exe file
running the mysqld.exe file
my xampp mysql service restarted successfully
I'm not sure if this will also work for your case, but it surely did for me, and I've yet to encounter the answer here.
go to Xampp/mysql/bin/my.ini
add the following line:
innodb_force_recovery = 1
(I think anything > 0 works here, also... it might be handy to make a backup of the file just to be on the safe side.)
You should now be able to successfully start your mySQL service.
This is an alternate solution instead of solving the above problem. I think you used windows installer for xampp, instead of that Download the zip file and keep it under c:\xampp. Use this link for downloading in zip format.
http://www.apachefriends.org/download.php?xampp-win32-1.7.7-VC9.zip
If you feel the zip file format is huge. Use 7zip file format.
http://www.apachefriends.org/download.php?xampp-win32-1.7.7-VC9.7z
Earlier I used to have same problem, solved it in this way.
Did you by any chance update your old install and then copy/paste your old 'htdocs' and 'mysql data' files to the upgrade files?
Have just run into the same problem, which I solved by uninstalling then re installing. Copying only my Htdocs over then re building my database... A pain but as I am only in Development and using Symfony2 rebuilding my database with fixtures was pretty painless.
Hope this is of some help.
Doug.
I had a similar problem that was caused by the TCP port needed for one for the services already being used by another application. In my case it was Skype using ports 80 and 443 as fall-back.
You can check if any of the needed TCP ports are used by another application by running the following at the command prompt:
c:>netstat /a
The offending connection will be listed as "LISTENING" in state STATE column. Then it's up to you to figure out what application is using the port. There is a nice tool called portmon for that.
The ports you'll need are 80, 3360... (anyone can expand on this?)
This is how I solved it:
xampp control panel > config > service & port settings > apache > mainport > 80 (default) change to 81.
open xampp > apache > cnonf > httpd.conf
3 search for ServerName localhost:80 change to ServerName localhost:81
search for Listen 80 change to Listen 81
Start Xampp > apache
open http://localhost:81/phpmyadmin/
whoaa its working
This worked for me, actually checking the 'mysql' service is not disabled. Turns out it was disabled.
how to check?
windows + R (opens run window)
type in services.msc
check if the service mysql is set as disabled. (change it to automatic)
This helped me with my unknown Phpmyadmin not starting issue.
If nothing helps, follow the steps mentioned in the below link. There are 3 methods to solve the problem. I hope, it will help you as well :)
For your convenience, I am writing down the steps of one of the methods which helped me to solved the problem
First of all stop all the services running in xampp control panel
Go to xampp > mysql >
Rename the data folder to anything else, such as data-old.
Then rename the backup folder to data
That's it. Try starting apache and mysql services from xampp control panel. Go to the link mentioned below to learn more.
https://kinsta.com/knowledgebase/xampp-mysql-shutdown-unexpectedly/
I have problem starting the MySql server.
The log says:
InnoDB: Error in opening ./ibdata1
111220 16:16:43 InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.0/en/operating-system-error-codes.html
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
/usr/libexec/mysqld: Disk is full writing './mysql-bin.000028' (Errcode: 28). Waiting for someone to free space... Retry
in 60 secs
After I check the disk - it says it's full.
So, after searching for solution - I found that I need to purge the binary log.
However, in order to purge - I need to start the MySql server, but all the spacein the disk is taken by the binary log, so I can't start...
It's also not advised to simply delete the binary logs.
So, I am kind of stuck.
Can't run the mysql to purge logs and can't purge logs because can't run server.
Any help? :)
Edit: The disk contains only the logs, there's nothing else.
If the disk is ext[2|3|4] you can use tune2fs to set the portion of the disk reserved for root to 0, giving you maybe enough breathing room to start the server
this would be tune2fs -m 0 /dev/whatever (after unmounting, ofcourse)
Try to start the mysql server with the option --expire_logs_days=, it should delete the log and older than days directory at startup.
bye
Gianluca