On my macOS devices I use MAMP app by appsolute GmbH for local web development. So far, this is the perfect app for me to have a local server environment. But sometimes there are problems such as the following error message when I try to start the servers:
MySQL wasn't able to start. Please check log for more information
What causes this problem
The reasons for the problems with running MySQL server can be different in different cases. The most common problems with MySQL server not starting are the following:
- Another
mysql
service running on the same port. - The
mysql.sock.lock
file was not deleted. - The current user not having permissions to the file.
- The log file is corrupted.
- The database is corrupted.
To find out the exact cause of the problem, you need to look in the MySQL log file located in /Applications/MAMP/logs/
or /Library/Application Support/appsolute/MAMP/logs/
.
Most often, the problems listed above occur after an incorrect shutdown of the MAMP app. For example, when your computer was hard powered off, or you force the MAMP app to quit.
How to solve it
I have encountered this problem on many occasions, and in most cases the following solutions work:
- Kill other MySQL processes running. (Solution №1)
- Rename or delete the MySQL log files. (Solution №2)
- Delete the
mysql.sock.lock
file. (Solution №3)
Solution # 1
In this solution we will use the Activity Monitor app. You do not need to download and install anything, because it is already built into every macOS.
Quit MAMP app.
Launch the Activity Monitor app from the Utilities folder of your Applications folder, or use Spotlight to find it.
Type
mysqld
into the search field on the top right.Quit every process you find after your search.
Launch MAMP and click the
Start Servers
button.
If MySQL still refuses to start check the log file for error messages.
If you see this error, or a similar error with your mysql.user table
2018-09-06T14:39:07.778314Z 0 [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade. 2018-09-06T14:39:07.778359Z 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files. 2018-09-06T14:39:07.778614Z 0 [ERROR] Aborting
Do the following …
You can’t run a MySQL database upgrade because your MySQL server does not start in the first place, you could try to add the line “skip-grant-tables” to your MySQL configuration file at the end of the section “[mysqld]” and then try to restart the MySQL server. This will tell the server to ignore your defective users table during startup so it can be upgraded afterwards.
To add this in MAMP PRO, open your MySQL template file. Go to File > Edit Template > MySQL > my.cnf
[mysqld] … skip-grant-tables
Now start your servers.
The server should start and you should be able to perform a database upgrade via the MAMP PRO main menu “Tools > Upgrade MySQL Databases”.
Don’t forget to remove the added line afterwards and restart your MySQL Server.
Solution # 2
In this solution we will use the Finder. You do not need to download and install anything, because it is already built into every macOS.
Quit MAMP app.
- In the Finder, go to the folder
Applications
→MAMP
→db
→mysql56
.Note! The path to this folder may be different on your system. Try the following variants:
1)/Applications/MAMP/db/mysql56/
2)/Library/Application Support/appsolute/MAMP/db/mysql56
- Rename the two log files
ib_logfile0
andib_logfile1
toib_logfile0_bak
andib_logfile1_bak
. Both of these files will be automatically rebuilt by MAMP on the next launch.Note! Don’t delete these two files as you may need to return to them.
- Launch MAMP and click the
Start Servers
button.
Solution # 3
In this solution we will use the Finder. You do not need to download and install anything, because it is already built into every macOS.
Quit MAMP app.
- In the Finder, go to the folder
Applications
→MAMP
→tmp
→mysql
.Note! The path to this folder may be different on your system. Try the following variants:
1)/Applications/MAMP/tmp/mysql/
2)/Library/Application Support/appsolute/MAMP/tmp/mysql
Delete the lock file
mysql.sock.lock
. This file is a plain text file with a PID in it. This file will be automatically rebuilt by MAMP on the next launch.Launch MAMP and click the
Start Servers
button.
The Ultimate Fix
So sometimes, when starting MAMP server, the MySQL service fails to start. This means that any application that relies on a database connection will not work. After searching the web for a solution none of the popular posts could help me fix the problem. I then stumbled on a short post on stackoverflow.com that pointed me in the right direction.
To fix the issue (in my instance) was quite simple. Here are the steps to follow:
- Locate and open the my.cnf file. It should be located here: MAMP/conf/my.cnf
- Locate the line that says:
innodb_force_recovery = 0
and change it toinnodb_force_recovery = 1
- Save and close the file
- Quit and restart MAMP and Restart all services
That’s it. The MySQL service should start without a problem and the work can go on. I hope this has helped you in some way. Good luck.
Conclusion
That’s it, you’re done. Now the MAMP should start the MySql server without errors. So simple isn’t it?
If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!