I installed MySQL 5.7.24 via Homebrew on MacOS Mojave v 10.14.4 per this gist. Now, I'm trying to remove it, but can't.
When I run brew remove mysql I get Error: No available formula or cask with the name "mysql".
I can run brew uninstall --force mysql and follow all the instructions from the post linked below, but I can't get brew remove mysql to work.
How to uninstall MySQL 5.6 when installed by brew on macOS?
Here are the steps I'm following:
# stop mysql
brew services stop mysql#5.7
# force uninstall
brew uninstall --force mysql
# check for running instances
ps -ax | grep mysql | grep -v grep
# no running process to kill
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*
# restart computer
After all of this, when I run mysql --version I get mysql Ver 14.14 Distrib 5.7.24, for osx10.9.
Also, I thought that maybe I needed to specify mysql#5.7 instead of just mysql, but I still get the same error.
It works with the version number.
brew uninstall --force mysql#5.7
screenshotstrong text
Installed MySQL by issuing the following commands:
$ brew install mysql56
$ brew services start mysql#5.6
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 mysql#5.6
It shows:
Service `mysql#5.6` already started, use `brew services restart mysql#5.6` to restart.
But I can't find it in the process list.
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!
Problem:
Getting Cannot load from mysql.procs_priv. The table is probably corrupted when trying to create new mysql user.
Platform: OSX Yosemite, Homebrew
Tried all the below and DID NOT WORK:
Upgrading: mysql_upgrade -uroot -p
I had to use --force because of this: This installation of MySQL is already upgraded to 5.7.9, use --force if you still need to run mysql_upgrade
Next I had to use --skip-version-check because of this: Error: Server version (5.7.18) does not match with the version of the server (5.7.9) with which this program was built/distributed. You can use --skip-version-check to skip this check.
still didn't work after all that
Reducing the query to most obvious and taking out functions: CREATE USER 'newuser';, still throws same error.
Repairing the mysql.procs_priv table
Changing all the char columns in mysql.procs_priv to varchar, as suggested here. Well he suggested changing to text but that seemed too crazy for a core mysql table.
I think it will be better to use this:
mysql_upgrade -u root -p
Enter your password and wait a few seconds.
Completely removing mysql and reinstalling it worked (less than 15 mins).
1. UNINSTALL AND PURGE MYSQL FROM SYSTEM
Back up databases.
Stop and kill any MySQL processes. Check for processes with ps -ax | grep mysql
Uninstall mysql
brew remove mysql
brew cleanup
Remove all the residual files
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*
Unload previous auto login
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Remove previous config. Delete the line MYSQLCOM=-YES- from /etc/hostconfig
Remove previous preferences
sudo 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*
sudo rm -rf /private/var/db/receipts/*mysql*
sudo rm -rf /private/var/mysql
Optional, restart computer. I didn't.
2. INSTALL MYSQL
Install Mysql
brew install mysql
Set to run on startup
brew services start mysql
Secure the installation
mysql_secure_installation
First of all let me start by saying that I have read and tried all approaches that I found on the web and stack overflow.
What I get when I try to run
mysql.server start
or
sudo /usr/local/mysql/support-files/mysql.server start
is
ERROR! The server quit without updating PID file (/usr/local/var/mysql/hostname.local.pid).
What I get when I try to run:
mysql
is
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I also tried:
sudo mysqld_safe &
Clicking the mysql start button on system preferences.
Restart the computer
Reinstall mysql
Install older version of mysql
killall and then try to run mysql
sudo chmod -R 777 /usr/local/mysql/
`sudo chown -R mysql /var/lib/mysql/
rm /usr/local/var/mysql/localhost.err
sudo /usr/local/mysql/bin/mysqld_safe start
tried everything here: How to auto-load MySQL on startup on OS X Yosemite / El Capitan
I am out of ideas, I don't know what to do.
What I did to actually make it work:
killall -u username
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*
*Restart the computer
brew doctor and fix any errors
brew update
brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mysql.server start
I accidentally installed the PowerPC version of MySQL on my Intel Mac in Snow Leopard, and it installed without a problem but of course doesn't run properly. I just didn't pay enough attention. Now when I try to install the correct x86 version it says that it can't install because a newer version is already installed. A Google query led me to perform these actions/delete these files to uninstall it:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySQL*
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
And finally removed the line MYSQLCOM=-YES- from /etc/hostconfig
They haven't seemed to help at all. I am still receiving the same message about there being a newer version. I tried installing an even newer version (the current Beta) and it also gave me the same message about a newer version already being installed. I can't uninstall it from the Prefs Pane because I never installed the PrefPane also.
Try running also
sudo rm -rf /var/db/receipts/com.mysql.*
I also had entries in:
/Library/Receipts/InstallHistory.plist
that i had to delete.
If you installed mysql through brew then we can use command to uninstall mysql.
$ brew uninstall mysql
Uninstalling /usr/local/Cellar/mysql/5.6.19...
This worked for me.
ps -ax | grep mysql
*stop and kill any MySQL processes
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
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
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 your computer just to ensure any MySQL processes are killed
try to run mysql, it shouldn't work
OS version: 10.14.6
MYSQL version: 8.0.14
Goto System preferences -> MYSQL
Stop MySQL server
One option will be shown here to uninstall MYSQL 8 after stopping Mysql server
Aside from the long list of remove commands in your question, which seems quite comprehensive in my recent experience of exactly this issue, I found mysql.sock running in /private/var and removed that. I used
find / -name mysql -print 2> /dev/null
...to find anything that looked like a mysql directory or file and removed most of what came up (aside from Perl/Python access modules). You may also need to check that the daemon is not still running using Activity Monitor (or at the command line using ps -A). I found that mysqld was still running even after deleting the files.
I also had a config file at /etc/my.cnf that I needed to delete on my Mac OS X Snow Leopard install
It might be overkill but your MySQL command history can also be wiped from:
~/.mysql_history
You need to identify where MySQL was installed to before attempting to delete it.
I always use the Hivelogic guide to installing under Mac OS X which builds MySQL from source. When setting up the build you can specify a directory under which to install MySQL with the --prefix parameter. You should make sure the directory does not exist and attempt to install from source.
./configure --prefix=/usr/local/mysql --with-extra-charsets=complex \
--enable-thread-safe-client --enable-local-infile --enable-shared \
--with-plugins=innobase
You should also check /var/db/receipts and remove all entries that contain com.mysql.*
Using sudo rm -rf /var/db/receipts/com.mysql.* didn't work for me. I had to go into var/db/receipts and delete each one seperately.
For me, I had installed MariaDB years ago using homebrew. Correct uninstall procedure was:
brew uninstall mariadb.
I also found
/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
after using all of the other answers here to uninstall MySQL Community Server 8.0.15 from OS X 10.10.
This did the job for me:
brew uninstall mysql
brew uninstall --force mysql#<version_no>
exmample
brew uninstall --force mysql#5.7
to get version check cd /usr/local/Cellar
Remove MySQL completely
Open the Terminal
Use mysqldump to backup your databases
Check for MySQL processes with:
ps -ax | grep mysql
Stop and kill any MySQL processes
Analyze MySQL on HomeBrew:
brew remove mysql
brew cleanup
Remove files:
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*
Unload previous MySQL Auto-Login:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Remove previous MySQL Configuration:
subl /etc/hostconfig`
# Remove the line MYSQLCOM=-YES-
Remove previous MySQL Preferences:
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 your computer just to ensure any MySQL processes are killed
Try to run mysql, it shouldn't work
sudo find / | grep -i mysql
This worked like a charm for me. Just went through the list and ensured that anything MySQL related was deleted.