错误1045(28000):在MAC OSX上对用户'root'@'localhost'的访问被拒绝(使用密码:否) [英] ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) on MAC OSX

查看:1383
本文介绍了错误1045(28000):在MAC OSX上对用户'root'@'localhost'的访问被拒绝(使用密码:否)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的MAC OS X Yosemite上重新安装mysql.为此,我按照以下说明进行操作

I'm trying to reinstall mysql on my MAC OS X Yosemite. for this I followed the instruction as mentioned below

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.*

我也尝试过

brew uninstall mysql

在此之后,我使用命令brew install mysql使用homebrew安装了mysql. 安装后,当我尝试运行mysql -u root时,它会引发以下错误

after this I installed mysql using homebrew using command brew install mysql. After installation when I tried to run mysql -u root It throws the following error

错误1045(28000):对用户'root'@'localhost'的访问被拒绝(使用 密码:否)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

我没有为mysql设置密码.我不知道出了什么问题.任何建议都将不胜感激.谢谢

I didn't set password for mysql.I don't know what's going wrong.Any suggestion will be appreciated. Thank you

推荐答案

我用homebrew安装了mysql,并遇到了与您相同的问题,因为mysql已有一个具有现有密码的现有数据库.有关更多详细信息,请参见本文.

I installed mysql with homebrew and got the same problem as you because mysql has had an existing database with an existing password there. See this article for more details.

$ 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

这篇关于错误1045(28000):在MAC OSX上对用户'root'@'localhost'的访问被拒绝(使用密码:否)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆