XAMPP MySQL cannot start [duplicate] - mysql

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.

Related

Error: MySQL shutdown unexpectedly This may be due to a blocked port, missing dependencies [duplicate]

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.

XAMPP : Error: MySQL shutdown unexpectedly [duplicate]

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.

XAMPP: MYSQL stops working after I restart

I am having problems with starting MYSQL in XAMPP. Apache starts alright but then MYSQL keeps reporting an unexpected shutdown.
I was led to delete C:\xampp\mysql\data\ibdata1 and it works after that but that deletes all my databases and MYSQL stops working again after I restart my machine.
I went through the error logs and this is what I saw:
[ERROR] InnoDB: Attempted to open a previously opened tablespace.
Previous tablespace mysql/innodb_index_stats uses space ID: 2 at
filepath: .\mysql\innodb_index_stats.ibd. Cannot open tablespace
yiicrud/customer which uses space ID: 2 at filepath:
.\yiicrud\customer.ibd InnoDB: Error: could not open single-table
tablespace file .\yiicrud\customer.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.
Adding this line in my.cnf worked for me:
innodb_force_recovery = 1
There is a solution on this page: XAMPP/MySQL: could not open single-table tablespace file .\mysql\innodb_index_stats.ibd after restart of MySQL
Move (DON'T DELETE) those files, into another folder:
innodb_index_stats.frm <br>
innodb_table_stats.frm <br>
slave_worker_info.frm <br>
slave_master_info.frm <br>
slave_relay_log_info.frm <br>
and .ibd files with the same filename.
Try start MySQL.
Thanks a lot everyone.
I have able to solve it. It appears the database was created in a later version and was incompatible with this new version of xampp so i created the databases again and imported the tables into them. Previously I was importing the database with the create statements as well.
Had the idea from Salman's comment.
Try this
rename the XAMMP\mysql\data folder to any other name you wish (say data_old )
make a new folder in XAMMP\mysql name data and copy all the files in it including ibdata1
close all running programs and restart XAMPP
No need to copy files from data_old but if you do have previously constructed databases then you may copy some files from data_old.
The solution may come again. If it then you have to change the port to something else like 3308 in the config settings as well as in phpMyAdmin/config.inc.php.
If the problem stays still then its better to change the application which uses the port 3306 and set default settings in XAMPP.

How to solve "Error: MySQL shutdown unexpectedly"?

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.

1067 error on attempt to start MySQL

I've installed MySQL on Windows 7. When I'm trying to start MySQL service I'm getting error 1067: The process terminated unexpectedly. Log message:
101111 22:27:11 [Note] Plugin 'FEDERATED' is disabled.
C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld: Table 'mysql.plugin' doesn't exist
101111 22:27:11 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: Log scan progressed past the checkpoint lsn 0 37356
101111 22:27:11 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 44233
101111 22:27:11 InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
101111 22:27:12 InnoDB: Started; log sequence number 0 44233
101111 22:27:12 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
What can I do about it?
The solution was to install MySQL without spaces in installation path.
Windows 7, 64-bit
One more thing that prevents the mysqld windows service from running is if you have mysqld.exe already running (but not as a service) and occupying port 3306. When the service tries to start and sees that port 3306 is already taken, it fails.
Just open up the windows task manager and look for "mysqld.exe" under the Processes tab. If you see it, kill it and then try to start the service again.
c:\> net start [servicename]
example: c:\> net start MySQL
My issue happened right after a power failure. I got the error 1067 The process terminated unexpectedly. MySQL needless to say did not start. The answer was simple
Open mysql path\data
Remove (delete) both ib_logfile0 and ib_logfile1.
Start the service
The solution to the problem for me was looking in my install directory, finding the /data folder, and copying it's content to the data folder that was specified in my .ini/.cnf configuration file.
I just encountered a similar issue and I found that it is a permission problem. When I copy the database "data", I have to add the permission for "NETWORK SERVICE"
I had the same problem. In my case, it was "user error" (although the Windows installer should have been smarter about it and prevented me from committing such an error).
During installation, if you make changes to the default installation paths, make sure you use the same paths for both the "Server data files" on the Custom Setup screen and then later in the "InnoDB Tablespace Settings" during the "MySQL Server Instance Configuration Wizard"
I had a problem changing the datadir in my.ini for Windows 7.
I wanted the data to be stored on a different drive and I was moving this data from another PC by copying the whole folder. I changed datadir to desired drive and saved the my.ini file with no problems.
But mysql would not start. I opened my.ini file again and it appeared to have been changed.
Then, I noticed the date on the my.ini had not changed. So I had to change the security privileges to give me write access to it.
This time when I saved it, the date changed and mysql started up access to all the correct data.
Before messing with too much things, please check the user the service is trying to run as. In my case it was NETWORK this one did not have write permissions to some locations where it was needed. Changing the user to Local System Account did the trick. If the event viewer shows any error like "Can't create test file C:\Program Files\MySQL\MySQL Server 5.6\data\XXX.lower-test", there is a high probability for this solution to work.
Good luck!
I have mysql data folder replaced by a windows directory junction.
I suspect ib_logfile0/1 and/or ibdata1 is corrupted.
Just try to delete those files and computername.err. Then restart mysql service.
That's what I did, with success.
Copying ibdata1 files, after a full reinstallation of mysql, to the junction dir and replacing dir by the junction, restarting mysql, was not enough.
You have to let mysql rebuild those files.
Also check if all dirs which you wrote in the my.ini exists.
My problem was that tmpdir doeesn`t exist so MySQL daemon falls with error 1067.
[mysqld]
port= 3306
tmpdir = "C:/tmp"
In this case C:/tmp must exists.
Check the file "C:\Program Files\MySQL\MySQL Server 5.1\my.ini"
The datadir line in my.ini should specify a path. Check the contents of that datadir path. Does it contain a folder named "mysql" and another folder named "test"?
If not, here are two choices:
Change the datadir line in my.ini to the correct location. This will probably be C:\ProgramData\MySQL\MySQL Server 5.1\data
Clean out the existing contents of your datadir path. Copy the contents of the C:\ProgramData\MySQL\MySQL Server 5.1\data to your datadir path. Restarting the mysql service should rebuild your empty database.
In my instance it had nothing to do with spaces in the file name. I used the MSI installer custom configuration and opted to exclude the default databases, assuming it was just something like Northwind/Adventureworks. Nope, it includes the core MySql system database... once I added that to the installation it worked.
in my case innodb_data_home_dir was no longer correct because I had shuffled some drive letters around when I added a new drive to my system
In my case, I have unzipped XAMPP ina a second disk on my installation, "F". When I tried to start as a service, the return was "1067". The solution was to edit my.ini, inserting the "f:" drive in the files lines. It solved the problem.
The problem look like there is no data in the directory.
copy at least the mysql directory either from your previous directory or from C:\Program Files\MySQL\MySQL Server 5.5\data .
And then try again.
I had the same error and it was caused by non standard characters in the log files path.
In order to fix that I found my.ini config file (in my case C:\ProgramData\MySQL\MySQL Server 5.6\my.ini) and modified keys slow_query_log_file and log-error.
After that I managed to start MySQL service succesfully.
In my case, I had chosen a custom path for my log-files in the MySQL installer. I had put the log-files in my user-folder C:\Users\%MY_USERACCOUNT%\Documents\mysql-logs, and by default, NETWORK SERVICE (or any other non-administrator useraccount in Windows) does not have access to a user's folder.
I fixed this by changing security options for the log-folder, giving modify rights read/write/modify rights to NETWORK SERVICE.
I also get log with Table 'mysql.plugin' doesn't exist
if install MYSQL Server 5.1 by 'msiexec.exe'
DataDir I put as C:\MYSQL\MySQL_Server_5_1\data\
but to my surprise was create data in a C:\MYSQL\MySQL_Server_5_1\data\data
There are was add word data . So I change my.ini file from
datadir="C:/MySQL/MySQL_Server_5_1/Data/" .
to the
datadir="C:/MySQL/MySQL_Server_5_1/Data/data"
and then I can use
net start MYSQL51
and then mysqld.exe run and appear in a Task Manager
when looked at mysql log (.err file under data folder), i could see the following
21:41:47 UTC - mysqld got exception 0xc0000005 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.
I realized i was starting the service while i plugged usb. To be honest, the problem was resolved after i restarted my machine followed by restarting the service. In addition i removed ib_logfile0 and ib_logfile1 files before my restart. Though the event logger indicated "InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information
Blockquote
about forcing recovery.For more information, see Help and Support Center at http://www.mysql.com", i do not think so because i never changed any configurations.
Experienced the same error, below is the reason and solution that worked for me for mysql-5.7.14-winx64
reason: DATA folder to have some default folders and files which were missing
solution: delete everything from DATA folder, i assume its a fresh installation so backup anything that you need if at all. Then run this from the command prompt and it will create required files and folders
"mysqld --initialize --console"
now run "mysqld" and it should work well.
In my case, I had another MySQL version installed and running.
I found this by going into the mysql_error.log file.
I fix this by going to services and stopping the running MySQL version and setting up to a manual, and starting the mysql needed.
...an old one... anyway I had the same issue with MariaDB
In my case most pathes contain special characters like: #
Wrapping pathes in my.ini in double quotes made the trick - e.g.
datadir="C:/#windata64/db/MariaDB/data"
In my case, in order to delete a heavy schema from mysql server, just went to C:\ProgramData\MySQL\MySQL Server 5.7\Data and deleted relevant folder. But it was not being deleted because mysqld.exe was preventing it. so I stopped mysqld.exe, deleted the folder and then all the schemas went disappeared from the list in mysql workbench. No matter how much I tried to restart mysql service, it didnt unless I restored that folder from junk.
Hope it helps someone who tried the same shortcut as I did.
I run MariaDB (MySQL compatible) on two machines locally. I'm not sure what prompted the error and nothing I tried worked. So I stopped the service, deleted everything in MariaDB's directory (except the data directory) and copied the files from my secondary machine and everything is working well enough as far as I can tell.
For a live server it'd be a bit different and a super-guru might be able to add an insight comment (e.g. something outside of the data directory might have something to do with preventing data corruption or indexes in example?). I would just stop the service and copy the entire directory once every month or so and then start the service again.
I ran into the same errors. Similar approach for me. From what I can tell, there is something weird going on with the reference to the datadir in the my.ini file. Even when I manually edited it I could not seem to have any effect on it, until I blew EVERYTHING AWAY. Wish I had better news...do a DB backup first.
For me the key to getting this to work was:
1) Remove the previous installation from settings->control panel. Restart your machine.
2) Once machine comes back up, forcefully delete the previous installation directory.
[mine is C:\apps\MySQL\MySQLServer-5.5\, as I REFUSE to use c:\program files\..]
3) Forcefully delete the previous datadir directory [mine was c:\data\mysql].
4) Forcefully delete the previous default data directory [C:\Documents and Settings\All Users\Application Data\MySQL].
5) Re-run the install, selected the same installation directory. Skip the instance configurator/wizard at the end of the install.
6) Make sure the ../bin directory gets added to the path. Verify it.
7) Manually run the instance configurator/wizard.
Set the root password, port [3306].
It will try to start it. Again, mine FAILED to start
[duh! nothing new there!!!]
8) Now, manually edit the my.ini file in the install directory, and correct the datadir setting to be [datadir="C:/Data/MySQL/"] MATCH CAPITALIZATION !!!!
9) Verify the service is setup correctly via the command-prompt [sc qc mysql <enter>].
Should look like:
C:\dev\cmdz>sc qc mysql
[SC] GetServiceConfig SUCCESS
SERVICE_NAME: mysql
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : "C:\apps\MySQL\MySQLServer-5.5\bin\mysqld" --defaults-file="C:\apps\MySQL\MySQLServer-5.5\my.ini" MySQL
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : MySQL
DEPENDENCIES :
SERVICE_START_NAME : LocalSystem
10) Copy the contents of the default data-directory created under C:\Documents and Settings\All Users\Application Data\MySQL [basically everything in this directory to your desired data directory c:\data\mysql]. Make sure you get the C:\Documents and Settings\All Users\Application Data\MySQL\mysql directory. This has host.frm file, and others.
You should end up with a directory now of c:\data\MySQL\mysql...
11) Rename the default directory
C:\Documents and Settings\All Users\Application Data\MySQL
To
C:\Documents and Settings\All Users\Application Data\MySQLxxx
So it cannot find it...
12) Say a quick prayer...
13) Give it a kick start from command line with [net start mysql]
That got it working for me...
Best of Luck!
Something I just discovered was that in the setup I choose InnoDB, whereas in fact all my existing databases were in MyIsam format. I uninstalled and then re-installed choosing MyIsam and everything worked just fine.
If you are trying to run MySql on a Windows 10 installation with a GPT partition, please try this:
Todays systems are often running on a disk which is formatted in GPT. This is because Windows 10 needs such a partition to be installed. The problem is that MySql cant deal with this partition style and so it crashes. Here is my workaround:
Create a virtual disk: manual here
Format this VHD with MBR
Install MySql custom on your new VHD (dont forget to create a user for DB)
This should be it! :)
Reference Link:
Issue with MySql installation on Windows 10