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?
STOP! Please do NOT delete
ibdata1
file!
Deleting this file is like playing a Russian roulette with your databases, it could work and restablish everything, but also, probably could leave unusable every database you have.
Instead, first try using the MySQL backup folder which is included with XAMPP. So do the next:
mysql/data
to mysql/data_old
(you can use any name)mysql/data
mysql/backup
to the new mysql/data
foldermysql/data_old
to mysql/data
(skipping the mysql
, performance_schema
, and phpmyadmin
folders from data_old
)ibdata1
file from mysql/data_old
and replace it inside mysql/data
folderAnd, voilà!
IMPORTANT Deleting this file may render any existing MySQL data unusable. Use with caution
Hey I just did this and it worked:
C:\xampp\mysql\data
directoryibdata1
fileIt should work
It should fix it.
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.
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
.
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
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
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:
C:\xampp\mysql\data
test_database
.C:\xampp\mysql\data\mysql\backuptablespace
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:
C:\xampp\
and store it somewhere safe so you can get back to where you started.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.
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.
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.
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 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.
I solved similar MySQL error & I think this answer will help you to fix the same type of MySQL database error.
Solution:
Take Backup of MySQL “data” Folder
First of all you should create a backup of the “data” folder using any compression software.
Give a name like “data_backup.zip” or any type of compression you wish.
I used winrar compression software to compress & backup mysql “data” folder.
Rename the “data” folder
Create a new “data” folder
Copy content from “backup” folder
Transfer all MySQL projects Database, Data file & Log files
If you have many database which was used for various projects, then you have to transfer all database from “data-oldfiles” folder to “data” folder.
Copy all databases from the data-old files and paste to the data folder.
Now you have to copy the data file “ibdata1” & all log files “ib_logfile0, ib_logfile1 ” from data-old files folder to the data folder.
If you have many id_logiles then copied all of them.
Now Start MySQL from XAMPP.
Go to phpMyAdmin to check all databases are available & working.
Now start your any website project from localhost to check the MySQL database.
The Problem is solved !!
You can read the details tutorials on the link bellow: Error: MySQL shutdown unexpectedly – Solution in 5 easy steps
You can also watch video tutorials to solve the problem:
What worked for me is:
Logs
for MySql
in XAMPP panel
.3306
task manager(Ctrl+Shift+Esc)
then find mysqlid
and End the task
.Guys just make sure you dont have MySql Server installed. Because I have MySql server pre-installed and when I start mysql from xampp control panel some port conflicts are happening and its not working.. SO before starting the mysql from xampp control panel make sure mysql server is not installed. I use .net so I have installed mysql server in the Past. Uninstalling it solved my Problem....
Go to task manager And search mysqld and right click and select END TASK and refresh XAMPP
In my case in which I synced my mysql data and htdocs to dropbox, I just needed to delete the conflicted files in mysql/data folder and subfolders. The conflicted files can be identified by its names, dropbox will tell you that. It has solved the problem for me.
Config->Apache->Open httpd.conf. search for Listen or 80,update listen port to 8081 save and restart server. Oh and shutdown Skype if you have it.
For me I quit Skype, which was occupying port 80, then Apache ran happily on port 80, than I ran Skype and it picked another port this time.
if you are using MariaDB you can try this:
Make sure the system time is correct. Mine was set to the year 2040 somehow, correcting the date solved the problem.
i comment this statement in mysql/bin/my.ini
'innodb_additional_mem_pool_size=2M'
and it solve my problem. than you everyOne
For me, the problem was:
I used to hibernate
my PC instead of shutting down due to the scale of the project. I was lazy enough to reopen all programs.
Before trying anything else, I recommend you to do the following simple things. Otherwise, you will be messed up your MySQL server.
If not works,
Also, make sure to check 3306
& 5040
ports. These two ports are required to run MySQL on default settings.
Check @Ryan Williams answer to find of why it's good to run XAMPP as administrator.
I literally deleted every file from c:\xampp\mysql\data\ except my.ini and it works
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.
first of all, make a backup file of your database C:\xampp\mysql\data copy this file and past it somewhere in your pc. After this open, the data file and also open the XAMPP server try to delete the files step by step one by one after deleting each file try to run the MySQL server after deleting a single file as shown in the screenshot thus your databases won't delete. if the file deletion does not work then try to copy the same files from the backup folders and repeat this until it works... this is time taking but this worked for me I have solved this in 20 minutes.
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
Go to C:\xampp\mysql\backup.
Copy all files.
Paste them into C:\xampp\mysql\data.
If Windows asks you to replace some files, replace them.
If your XAMPP Control Panes is active close it.
Go to C:\xampp and find xampp-control, run it.
Start Apache, start MySQL.
That's it.
Enjoy!
For this, you need to click on the x option under Modules Services and make MYSQL services installed. Then start the services. Here you go.
If any of the things above do not work, make a back of Xampp directory and reinstall Xampp. That surely works!
If the crash message is "mysql.exe has stopped working". Just run xampp-control.exe as administrator will solve your problem instantly.
Rename below files from mysql/data ib_logfile0 ib_logfile1 ibdata1
my.cnf innodb_buffer_pool_size to 200M as per your ram innodb_log_buffer_size to 32M
Restart your apache server
hope it helps you
Create a Back up your mysql folder from C:\xampp\mysql
.
Then go to C:\xampp\mysql\backup
Copy all the files and paste it into C:\xampp\mysql\data
.
Then from your old backup folder see for ibdata1
file you can find it in C:\xampp\mysql\data
. Copy this file and paste in into C:\xampp\mysql\data
.
Now restart xampp and it should work.
There are a number of things I've tried. This is the 2nd time this has happened to me. On my first time, I've to reinstall my xampp. And on the third day, mysql crashed again. I've tried everything I found on the internet. Like, innodb_flush_method=normal in my.ini file and deleting ibdata1, ib_logfile1, ib_logfile0 files, and others but none of these works. So later I tried to run xampp with admin privilege and install apache and mysql as a service as it was instructed on xampp control panel itself. After starting mysql, I read error-log again and from there I came to know that one of my databases is responsible for this. That database file won't let mysql start. So I deleted everything in the data folder and then in cmd I navigated to C:/xampp/mysql/bin path and ran these commands:
mysqld --initialize
mysql_install_db
and mysql started running again. But my databases and data are lost.
That's the more precise answer and worked for me!!!! ! A cleaner way of undoing the damage is to revert your whole /mysql/data/ folder. Windows has built-in folder versioning — right click on /mysql/data/ and select Restore previous versions. You can then delete the current contents of the folder and replace it with the older version's contents. as mentioned above by Ryan Williams.
If none of the deletion of files work then probably your mysql service is not running. Go to services.msc and start mysql service
If none of the solutions listed here didn't work for you just like me, then
It worked for me.
Fixed it by reinstalling the Xampp.
If you don't want to go through all the technical stuff that the other proposes.
Back up the htdocs folder then uninstall Xampp, it will ask you if you want to retain the htdocs folder, opt-out. Completely uninstall, remove the remains. The install again, copy back your backed-up htdocs folder.
you're done.
Source: Stackoverflow.com