gpt4 book ai didi

mysql - 在 macOS 上通过 brew 安装时如何卸载 MySQL 5.6?

转载 作者:可可西里 更新时间:2023-11-01 08:02:19 26 4
gpt4 key购买 nike

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

但是在进程列表中找不到。

最佳答案

堆栈溢出。

我会回答这个问题,但请务必check for existing questions因为已经有人问过了。

试试这个

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

# 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 的失败,它们根本不存在。

希望这对您有所帮助,祝您有美好的一天!

关于mysql - 在 macOS 上通过 brew 安装时如何卸载 MySQL 5.6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52161511/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com