Fixing MySQL issues on macOS

Recently faced some issues with MySQL after a macOS update, though it was running perfectly on the old version.
The main issues
Though the system-preference pane the MySQL icon says its running but when I checked for
ps -ax | grep mysql
and it didn’t give any trace saying that MySQL is running.
- Even if we manually stop/start from the preference pane, nothing was really happening, means MySQL was not working for me
- If you’re also going through the same I request to do a fresh installation of MySQL by following the below mentioned Steps.
Solution for the Pain
- Check whether there is any existing MySQL processing running by giving the command
ps -ax | grep mysql
- If found kill it using
kill -9 {PID}
or using launchctl
sudo launchctl unload -w /Library/LaunchDaemon/com.mysql.mysql.plist
- I suppose you’re familiar with HomeBrew , if so give the command
brew remove mysql
- Then issue the command
brew cleanup
- Then find for MySQL traces in your system by issuing the command
sudo find / | grep -i mysql
it will return a long list and use rm command to remove the significant.( Assuming you’ve the knowledge of the system)
- Then delete the files one by one using
rm
command i.e
rm /usr/local/mysql*sudo rm -rf /usr/local/var/mysql*sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
- Even if you uninstall MySQL using Homebrew, the preference pane will be there so in-order to remove that issue the below commands.
Be careful using these commands
sudo rm ~/Library/PreferencePanes/My* sudo rm -rf /Library/Receipts/mysql*sudo rm -rf /private/var/db/receipts/mysql*
- The above gonna fix all the existing issues now you need to use brew again, and check whether brew is updated by giving brew update command
- Then you can install the latest MySQL again by brew install mysql and follow the instructions on terminal.
- After that you can start mysql server using any one of the below commands
brew services start mysql mysql.server start
- Verify it by using the command
ps -ax | grep mysql
Note: here you won’t be getting that icon on the preference pane again but there are workarounds to achieve that as well