Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall MySQL 5.6 when installed by brew on macOS?

Installed MySQL by issuing the following commands:

$ brew install mysql56
$ brew services start [email protected]

Now I can't access it:

$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Want to uninstall it and tried the following:

brew remove mysql
brew cleanup

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySql*

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

rm -rf ~/Library/PreferencePanes/My*    
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

(Restart computer)

Now work.

When I install it again and run:

brew intall mysql56
brew services start [email protected]

It shows:

Service `[email protected]` already started, use `brew services restart [email protected]` to restart.

But I can't find it in the process list.

like image 980
zseikyocho Avatar asked Sep 04 '18 01:09

zseikyocho


People also ask

How do I Uninstall MySQL 5?

To uninstall MySQL on Windows, make sure that your first stop the running server. Once the server is stopped, you can uninstall MySQL via the Windows "Control Panel". Go to "Programs and Features" and select "MySQL" => "Uninstall".

How do I Uninstall MySQL installation?

Removing MySQL Workbench After Installation from MySQL Installer. From the MySQL Installer dashboard, click Remove to open the Select Products to Remove page. Select MySQL Workbench (the status changes to Ready to remove ) and click Next. Click Execute to uninstall all of the selected products.

Where is MySQL after installed on Mac?

By default, the MySQL directories are installed under /usr/local/ . Even better, add /usr/local/mysql/bin to your PATH environment variable. You can do this by modifying the appropriate startup file for your shell. For more information, see Invoking MySQL Programs.


1 Answers

to Stack Overflow.

I will answer this but, please be sure to check for existing questions as this has already been asked.

Try this

brew uninstall --force mysql

Or From Google First result being from CoderWall

Find Any Running Instances

ps -ax | grep mysql | grep -v grep

# OR for only the running `PID`

ps -ef | grep mysql | grep -v grep | awk '{print $2}'

# OR this If you have this on your machine, I recommend using 

pgrep -f mysql

If running the kill process

kill 24024824082408   # change this number to what was returned in the grep 

Save your database data

This will save your MySQL Data Folder to your desktop in a folder mysqldata.

# I backup my data from mysql to my desktop
mkdir ~/Desktop/mysqldata/

# data
cp -r /usr/local/mysql/data ~/Desktop/mysqldata

Save your MySQL Workbench Data for migration.

# MySQL workbench active sessions including the unsaved query windows
cp -r ~/Library/Application\ Support/MySQL/Workbench/sql_* ~/Desktop/mysqldata

# data this is a log containing queries that were logged at some point, more of a `just in case`
cp ~/Library/Application\ Support/MySQL/Workbench/log/sql_actions_unconnected.log ~/Desktop/mysqldata/sql_actions_unconnected.sql

# data of user snippets as people forget about this.
cp /Users/`id -un`/Library/Application\ Support/MySQL/Workbench/snippets/User\ Snippets.txt ~/Desktop/mysqldata/UserSnippets.txt

Removal and Cleanup

brew remove mysql
brew cleanup
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

Edit (if applicable) vi /etc/hostconfig and remove the line MYSQLCOM=-YES-

Restart your computer if you want to ensure any MySQL processes are killed Try to run mysql, it shouldn't work.

Don't worry about some of the rm's failing they are just nonexistent.

Hope this helps & have a great day!

like image 176
JayRizzo Avatar answered Oct 08 '22 08:10

JayRizzo