【Mac MySql异常】Bug 1045 (28000): Access denied to user 'root'@'localhost' on MAC OSX (use password: no) (ERROR 1045 (28000):
1、清除本地MySql相关
重装Mysql之前先删除本地MySql的相关文件。
sudo rm /usr/local/mysql sudo rm -rf /usr/local/mysql* sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm -rf /Library/PreferencePanes/MySQL* vim /etc/hostconfig and removed the line MYSQLCOM=-YES- rm -rf ~/Library/PreferencePanes/MySQL* sudo rm -rf /Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm -rf /var/db/receipts/com.mysql.*
也可以直接在设置偏好设置里面执行Uninstall,记得在弹窗中,勾选清楚相关文件
2、安装MySql
$ brew services stop mysql $ pkill mysqld $ rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!! $ brew postinstall mysql $ brew services restart mysql $ mysql -uroot