Cách chữa không khởi động được mysql tốt nhất từng làm 3306 (ok)
https://stackoverflow.com/questions/18022809/xampp-mysql-shutdown-unexpectedly
Last updated
https://stackoverflow.com/questions/18022809/xampp-mysql-shutdown-unexpectedly
Last updated
Cach moi: https://stackoverflow.com/questions/18022809/how-to-solve-error-mysql-shutdown-unexpectedly
Copy 3 thu muc trong bakup
Copy 3 thu muc trong C:\xampp\mysql\backup
Buoc 1: mysql, performance_schema, phpmyadmin
Buoc 2: copy du lieu web cu loi vao day
Đọc thêm
Asked 7 years, 9 months agoActive 4 days agoViewed 858k times183106
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.
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:
Rename the folder mysql/data
to mysql/data_old
(you can use any name)
Create a new folder mysql/data
Copy the content that resides in mysql/backup
to the new mysql/data
folder
Copy all your database folders that are in mysql/data_old
to mysql/data
(skipping the mysql
, performance_schema
, and phpmyadmin
folders from data_old
)
Finally copy the ibdata1
file from mysql/data_old
and replace it inside mysql/data
folder
Start MySQL from XAMPP control panel
44This is the best answer, doesn't ask you to delete any files or folder and importantly, it works. – gegobyte Jun 30 '20 at 6:46
29This is the best answer – Kevin E. Ogbonna Jul 5 '20 at 9:51
11I've resorted to this answer sooo many times that I even wrote a PowerShell script to automate the process: gist.github.com/josemmo/24e35f2b4984a4370ce2c164f5956437 – josemmo Aug 28 '20 at 18:50
9this should be the top answer – zero8 Sep 1 '20 at 5:52
5Yes, this is best answer. my bad I have not tried it first. Excellent answer. You saved my db data and lots of hassles. Hats off to you man! – Nilesh Sep 10 '20 at 16:20
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
32This works and should likely be marked as the correct answer. However rename the file to ibdata1.bak rather than delete it. Just to be save. – Lorenz Lo Sauer Sep 3 '13 at 12:13
23This will, of course, destroy all the data which was stored in that file (all the InnoDB tables which were created before setting innodb_file_per_table
to enabled). The methods suggested in the log message seem suprtior to me. – Tgr Oct 12 '13 at 10:50
17I also had to delete ib_logfile0
and ib_logfile1
to get it to work – Allan Macmillan Jun 19 '14 at 18:58
13Ouch! Blowing away ibdata1
is equivalent to losing all your data (or at least all that are ENGINE=Innodb
! – Rick James Mar 14 '17 at 4:16
19The most upvoted unexplained reckless thing you can do – user10089632 Jan 14 '18 at 10:36
Go to mysql/data/
Delete all random files (except the actual database folders)
Restart Apache and MySQL.
11It deleted all my data. There was a lot of data. – Paras Mar 17 '17 at 11:08
12I confirm that deleting files will make all DB unusable. Table files are there but they can't display. – Adrian P. Apr 25 '18 at 0:27
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.
Love You @Matthew Magante. You have solved my problem which I was facing for last one year. Thanks a lot. – Kashif Iftikhar Mar 24 '20 at 6:20
1Now, I am not getting that error in xampp but still phpmyadmin is not workin g – Sarvesh Tiwari Apr 16 '20 at 10:45
Thanks, @fabrizio valencia fix was doing well but after two or three times it was not working anymore and this solved as second fix. – Fer Toasted Nov 14 '20 at 16:18
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.
1This should be accepted as correct answer. If you remove ibdata1, there will be tons of orphaned tables. – sean Mar 3 '15 at 20:05
Thanks, you fixed my problem after trying a ton of different things. – user3089840 Dec 23 '15 at 21:42
also fixed issue for me – Gaz Smith Apr 29 '19 at 8:36
Nice explannation :D Thank you. – logbasex Jun 4 '20 at 3:21
The 'Restore previous versions' option only works if you regularly create Restore Points in Windows. :( – nockieboy Jun 9 '20 at 9:04
My Xampp MySQL worked just follows as below:
this is the most effective way for me !! – Youssef Boudaya Jun 4 '20 at 14:17
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.
7Read about what you are doing, before you do it: dev.mysql.com/doc/refman/5.0/en/forcing-innodb-recovery.html – marcovtwout Sep 30 '14 at 11:56
Thank you so much, really helped me a lot. – Lohn Claidon Oct 28 '14 at 5:10
5it's better to start with value 1 and increment it each time it didn't work. Values 1-3 are considered save. 4-6 can corrupt data! – CoR Aug 18 '15 at 20:26
This helped me. As pointed out, use values 1-3 first. 2 worked on me. I had to dump all my database, reset mysql data using the back up folder then import the dumps. This is helpful if you want to keep your data – claw68 Sep 13 '20 at 5:42
I got the same kind of error in my C:\xampp\mysql\data\mysql_error.log
when trying to start mysql.
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:
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.
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.
1Thank you, none of the other options worked for me, this one did. Very grateful – user3808307 Jan 27 '20 at 19:58
@user3808307 I'm glad it helped you :) – Sobhan Jan 28 '20 at 6:28
thank you so much! this was really simple to do and it worked :) – Aditi Feb 25 at 6:35
move xampp/mysql/backup
files into xampp/mysql/data
Thanks man worked like a charm for me. :) – Utpal - Ur Best Pal Dec 16 '20 at 6:46
Best Solution You saved my time thanks – Siraj Ali Mar 1 at 9:51
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.
Changing port worked for me and no other method worked – Zobia Kanwal Dec 18 '20 at 13:09
This is not a valid answer! – abhiarora Jan 11 '17 at 15:37
Not valid answer – Soumyajit Dutta Aug 1 '19 at 15:10
No solution above worked for me. then I did below:
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.
i changed it to ,
Thanks, it helped me. That soultion with deleting ib1 created for me new problems to solve. – Skotee Feb 17 '20 at 0:21
Solution:
Go to the “data” directory in the mysql database.
I installed XAMPP on D: drive on my computer & the mysql “data” directory location of my computer was “D:\xampp\mysql\data\”. You may have different location.
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
Rename the “data” folder to “data-oldfiles”. This is very important to rename the data directory to any new directory name.
Create a new “data” folder
Create a new folder and give the folder name as “data“
To solve the problem we need to create a new “data” directory in the mysql database.
Copy content from “backup” folder
Go to the “backup” folder and copy all files.
Paste the files from backup folder to data folder
Now start the MySQL database from XAMPP.
Your MySQL database will start properly without showing any error.
Transfer all MySQL projects Database, Data file & 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 !!
Now you will see the problem is solved and the error message “Error: MySQL shutdown unexpectedly.” will not show again.
If you have any question on this issue please feel free to ask any question in the comments section.
You can read the details tutorials on the link 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:
First I open Logs
for MySql
in XAMPP panel
.
At the end it says you are running another instance of mysqlid in port 3306
I opened my task manager(Ctrl+Shift+Esc)
then find mysqlid
and End the task
.
I had encountered the same issue, but all I had to do was close the XAMPP Control panel, go to the folder in which XAMPP is installed, find xampp-control.exe and run as administrator and then start the services.
2Yeah, that fixed it. I swear I reinstalled before posting that, but I guess not. Thanks :) – Austin Aug 3 '13 at 21:01
if you are using MariaDB you can try this:
Go to mysql/data/
Rename aria_log_control to aria_log_control_old
Restart "Mysql"
i comment this statement in mysql/bin/my.ini
I don't have that line at all – Vipul Hadiya Sep 11 '19 at 6:06
Are you on windows ? what is your xampp version ? – Boston Kenne Sep 11 '19 at 7:07
Yes, Win 10 with XAMPP 3.2.4 – Vipul Hadiya Sep 11 '19 at 7:09
did you have access to your mysql/bin/my.ini file? – Boston Kenne Sep 11 '19 at 8:09
gist.github.com/susanBuck/52f8a8508d94834332b1d565fb3a0e00 see this link, and check your file location that it's supposed to be in C:\xampp\mysql\bin\my.ini , find the line innodb_additional_mem_pool_size and comment it. – Boston Kenne Sep 11 '19 at 8:16
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.ShareImprove this answerFollowanswered Oct 31 '18 at 12:46
What is the cause of these errors and how can I rectify them?mysqlxamppShareImprove this questionFollowedited Aug 10 '17 at 3:17asked Aug 2 '13 at 17:27Austin1,84333 gold badges1010 silver badges1111 bronze badgesAdd a comment
And, voilà!ShareImprove this answerFollowedited Jan 24 at 16:30answered May 17 '20 at 22:20Fabrizio Valencia6,22522 gold badges1111 silver badges1818 bronze badges
It should workShareImprove this answerFollowedited Nov 6 '20 at 20:28Machavity♦28.6k2525 gold badges7575 silver badges9191 bronze badgesanswered Aug 10 '13 at 13:14Kratos2,16911 gold badge99 silver badges22 bronze badges
It should fix it.ShareImprove this answerFollowedited Jan 21 '16 at 13:06answered Jan 21 '16 at 12:55Kerim1,0071212 silver badges1111 bronze badges
Then delete or put into comment the port 3306 and change it to 8111 then run xamp with administrator and its work well.ShareImprove this answerFollowedited Nov 8 '20 at 16:22CloudBalancing32011 gold badge22 silver badges1414 bronze badgesanswered Jan 28 '20 at 2:36Mathew Magante71211 gold badge1111 silver badges2727 bronze badges
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
.ShareImprove this answerFollowanswered Nov 7 '13 at 15:37Ryan Williams60755 silver badges1111 bronze badges
ShareImprove this answerFollowanswered Dec 4 '16 at 9:45matinict2,08422 gold badges2424 silver badges3434 bronze badges
ShareImprove this answerFollowedited May 5 '14 at 8:15Harmlezz7,5042323 silver badges3434 bronze badgesanswered Dec 16 '13 at 17:40aog44433 silver badges1414 bronze badges
Something you did screwed up the mysql server. An uninstall and reinstall of XAMPP should undo the corruption.ShareImprove this answerFollowedited Nov 8 '13 at 0:48answered Aug 8 '13 at 17:25Eric Leschinski123k8181 gold badges381381 silver badges321321 bronze badgesAdd a comment7
Hope this will work!ShareImprove this answerFollowanswered Aug 13 '13 at 18:31SITHU13366 bronze badgesAdd a comment6
ShareImprove this answerFollowedited Dec 3 '19 at 10:40tomerpacific3,03977 gold badges2121 silver badges4141 bronze badgesanswered Dec 3 '19 at 8:54Sobhan57155 silver badges1919 bronze badges
Hope it helps!ShareImprove this answerFollowanswered May 16 '20 at 21:36Jayant Rajwani49855 silver badges1414 bronze badgesAdd a comment6
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 controllerShareImprove this answerFollowedited Dec 10 '20 at 17:14Cristik24.7k1818 gold badges7070 silver badges9797 bronze badgesanswered Dec 10 '20 at 14:41Swap8511 silver badge99 bronze badges
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. ShareImprove this answerFollowanswered Nov 28 '20 at 8:28Rasul Ebrahimzadeh8711 silver badge99 bronze badges
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.ShareImprove this answerFollowanswered Jan 11 '17 at 15:18kyzen18511 gold badge11 silver badge1313 bronze badges
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.ShareImprove this answerFollowanswered Jan 17 '17 at 13:33Aammad Ullah23633 silver badges1111 bronze badgesAdd a comment3
Then run as Administrator.Finally this worked for me.ShareImprove this answerFollowanswered Mar 26 '18 at 7:24Sksaif Uddin3971010 silver badges1818 bronze badgesAdd a comment3
I have resolved the problem by ending the task for mysqlid on Task Manager.ShareImprove this answerFollowanswered Dec 17 '19 at 6:56Mandeep Singh Gill53944 silver badges44 bronze badges
I solved similar MySQL error & I think this answer will help you to fix the same type of MySQL database error.
[Solved] Error: MySQL shutdown unexpectedlyShareImprove this answerFollowedited Jul 24 '20 at 19:15answered Jul 24 '20 at 19:06shafiq24105133 bronze badgesAdd a comment2
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....ShareImprove this answerFollowanswered May 14 '18 at 7:24Gvs Akhil1,46411 gold badge1111 silver badges2424 bronze badgesAdd a comment2
ShareImprove this answerFollowanswered Mar 24 '20 at 18:26سیدرسول میرعظیمی47455 silver badges1010 bronze badgesAdd a comment2
ShareImprove this answerFollowanswered Aug 1 '20 at 4:32shibashis3566 bronze badgesAdd a comment2
ShareImprove this answerFollowedited Dec 13 '20 at 18:09answered Dec 13 '20 at 18:04Curious10611 silver badge44 bronze badgesAdd a comment1
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.ShareImprove this answerFollowanswered Aug 2 '13 at 17:56Mihai22.9k77 gold badges5757 silver badges7272 bronze badges
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.ShareImprove this answerFollowanswered Jan 11 '15 at 9:15maurisrx30933 silver badges99 bronze badgesAdd a comment1
Make sure the system time is correct. Mine was set to the year 2040 somehow, correcting the date solved the problem.ShareImprove this answerFollowedited Dec 26 '16 at 9:17user24770221.8k1313 gold badges101101 silver badges145145 bronze badgesanswered Dec 26 '16 at 6:11shakee933,73922 gold badges2323 silver badges2929 bronze badgesAdd a comment1
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.ShareImprove this answerFollowedited May 14 '17 at 3:20Tiffany6091111 silver badges2626 bronze badgesanswered Jun 28 '15 at 15:57sudhanshu33366 silver badges2121 bronze badgesAdd a comment1
ShareImprove this answerFollowanswered Mar 28 '18 at 15:00Leo1,58333 gold badges1616 silver badges2323 bronze badgesAdd a comment1
and it solve my problem. than you everyOneShareImprove this answerFollowanswered Jun 20 '18 at 9:05Boston Kenne62099 silver badges1212 bronze badges