What to do if the MAMP app fails to start MySQL server? (Using the Terminal)
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
This article is intended for experienced users. We will use the Terminal app to solve the problem. For regular users, I recommend reading another article about this problem. It describes how to do almost the same thing using the Finder, instead of using commands in the Terminal.
I’m using version 4.2.1 of the MAMP app, but in your case there can be any other version of the MAMP app. If you use the non-standard version of the app, but the PRO one, then in the following steps, replace “MAMP” with “MAMP PRO”, respectively.
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)
We will use the Terminal app to solve the problem. You do not need to download and install anything, because it is already built into every macOS.
-
Quit MAMP app.
-
Launch the Terminal app from the Utilities folder of your Applications folder, or use Spotlight to find it.
- Enter the command below to show any MySQL processes currently running.
pgrep mysql
Note! This is an optional step, you can skip it.
- Enter the command below to kill MySQL processes.
killall -9 mysqld
Note! If you get the following message
No matching processes belonging to you were found
then try addsudo
to the command above so you get the followingsudo killall -9 mysqld
. It will ask for the administrator password. - To verify that they no longer exist, repeat the
pgrep
command and you should not have any processes returned.pgrep mysql
Note! This is an optional step, you can skip it.
- Launch MAMP and click the
Start Servers
button.
-
Quit MAMP app.
-
Launch the Terminal app from the Utilities folder of your Applications folder, or use Spotlight to find it.
- Enter the command below to 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.mv /Applications/MAMP/db/mysql56/ib_logfile0 /Applications/MAMP/db/mysql56/ib_logfile0_bak mv /Applications/MAMP/db/mysql56/ib_logfile1 /Applications/MAMP/db/mysql56/ib_logfile1_bak
Note! The path to these files may be different on your system. Try the following variants:
1)/Applications/MAMP/db/mysql56/
2)/Library/Application Support/appsolute/MAMP/db/mysql56
Note! Don’t delete these two files as you may need to return to them. - Launch MAMP and click the
Start Servers
button.
-
Quit MAMP app.
-
Launch the Terminal app from the Utilities folder of your Applications folder, or use Spotlight to find it.
- Enter the command below to 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.rm /Applications/MAMP/tmp/mysql/mysql.sock.lock
Note! The path to this file may be different on your system. Try the following variants:
1)/Applications/MAMP/tmp/mysql/mysql.sock.lock
2)/Library/Application Support/appsolute/MAMP/tmp/mysql/mysql.sock.lock
- Launch MAMP and click the
Start Servers
button.
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!
If this article has helped you solve the problem then please leave a comment
Thanks for reading!
Arthur is a designer and full stack software engineer. He is the founder of Space X-Chimp and the blog My Cyber Universe. His personal website can be found at arthurgareginyan.com.