通过发出以下命令来安装MySQL:
$ brew install mysql56
$ brew services start mysql@5.6
现在我无法访问它:
$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
想要卸载它并尝试以下操作:
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)
现在工作。
当我再次安装并运行时:
brew intall mysql56
brew services start mysql@5.6
它显示:
Service `mysql@5.6` already started, use `brew services restart mysql@5.6` to restart.
但是我在进程列表中找不到它。
答案 0 :(得分:2)
堆栈溢出。
我会回答这个问题,但是请务必check for existing questions,因为这已经被要求了。
brew uninstall --force mysql
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
kill 24024824082408 # change this number to what was returned in the grep
这会将您的MySQL数据文件夹保存到文件夹mysqldata
中的桌面上。
# I backup my data from mysql to my desktop
mkdir ~/Desktop/mysqldata/
# data
cp -r /usr/local/mysql/data ~/Desktop/mysqldata
# 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
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*
编辑(如果适用)vi /etc/hostconfig
并删除行MYSQLCOM=-YES-
如果要确保杀死所有MySQL进程,请重新启动计算机 尝试运行mysql,它不起作用。
不用担心某些rm
失败了,只是不存在。
希望这对您有帮助并度过愉快的一天!