284
Views

As you may know from a recent post, I decided to use MAMP for a more native full stack experience on my Mac. Today I noticed that I wasn’t able to start my MySql server and here are the steps I took to get it working.

Delete The MySQL Logs

I found a few options for doing this but I liked the idea of backing up before removing the files. Make your backup like this.

mkdir ~/sqlbackup

Then you will want to copy the files we plan to delete to this folder.

cp /Applications/MAMP/db/mysql56/* ~/sqlbackup

You should now have some files, not directories in your ~/sqlbackp folder. Now we can remove the log files in the root of /Applications/MAMP/db/mysql56/ to resolve the app not starting.

rm /Applications/MAMP/db/mysql56/*

You will see a few notices about directories because the command we ran doesn’t remove directories or their contents, just the files in the root directory. They are re-generated the next time MySQL starts.

Automating The Process

We can make a bash script to automate this process. I like to have a folder called scripts in my root folder ~/ to make tasks I preform easily accessible.

mkdir ~/scripts

Lets create the script.

nano ~/scripts/sqlfix

Now let’s write the script commands.

#!/bin/bash
#This line reminds us that this script cleans up the MySQL log files to get MAM$

#Lets delete the old folder if any exists from running the script last time. Us$

rm -r ~/sqlbackup > /dev/null > /dev/null 2>&1
mkdir ~/sqlbackup > /dev/null > /dev/null 2>&1

#Now make the backup. Update this next line with your directory/sql version min$

cp /Applications/MAMP/db/mysql56/* ~/sqlbackup > /dev/null 2>&1

#Lastly we need to delete the current contense of cp -r /Applications/MAMP/db/m$

rm /Applications/MAMP/db/mysql56/* > /dev/null > /dev/null 2>&1

echo "You can now start your MySQL DB"
  • Just a few things to remember about using the script, you need to update the mysql56 to whatever your mysql folder is and this will change as it’s based on sql version.
  • If you run it twice in a row, it will overwrite the current backup so run it once and if you still can’t get it to start, troubleshoot manually.
  • This script is a quick option incase this ends up happening a lot. I do recommend updating MAMP and keeping track of releases or bugs if this becomes a continued issue.
  • And of course this is offered as is and I’m not responsible for any issues that may come of using the script. I use it and have had no issues this far.

Conclusion

It seems that MAMP is going to work for what I use it for and is a better alternative for me to XAMPP for now. If you end up with the same issue regularly, it may be wise to try to determine why it’s happening and report it but until it’s fixed, here is an easy way to keep your workflow on track. Share your experiences or comment below if you’ve had this issue or use this method to fix it.

Article Categories:
Coding
SDATIC

Web developer and former photographer by trade...gamer and all around tech enthusiast in his free time. Christoph started sdatic.com as a way to organize his ideas, research, notes and interests. He also found it enjoyable to connect and share with others who parallel his interests. Everything you see here is a resource that he found useful or interesting and he hopes that you will too.

All Comments

Leave a Reply

Your email address will not be published. Required fields are marked *