brew在macos上安装MySQL5.6时如何卸载?

xuo3flqw  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(470)

通过发出以下命令安装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.

但我在进程列表中找不到它。

wnrlj8wa

wnrlj8wa1#

堆栈溢出。
我会回答这个问题,但请务必检查现有的问题,因为这已经被问到了。

试试这个

brew uninstall --force mysql

或者来自google的第一个结果来自coderwall

查找任何正在运行的示例

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进程

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工作台数据以进行迁移。


# 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 他们根本不存在。
希望这对你有帮助&祝你有一个美好的一天!

相关问题