MySQL Access拒绝错误

时间:2013-11-05 21:51:43

标签: mysql jdbc

我正在尝试在Mac OS 10.8上安装mySQL并设置用户帐户。 注意在终端窗口中使用命令行时,我是一名初学者。

我使用这些说明安装: http://www.macminivault.com/mysql-mountain-lion/

我在这里为所有用户设置了自己的密码:

 GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'mypass' WITH GRANT OPTION;
quit

每当我尝试在命令行上以root用户身份执行mySQL时,我都会得到:

Ciarans-MacBook-Pro:~ callanmooneys$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

我在网上阅读并尝试了各种各样的事情,包括尝试更改密码:

mysqladmin -u root -pyourcurrentmysqlrootpassword password yournewmysqlrootpassword,
it returns -> 
    -> USE mysql
    -> 

如果我只是输入'mysql'并启动mySQL监视器,那么尝试创建一个用户帐户:

mysql> USE mysql
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
mysql> 

也在论坛上尝试了答案:access is denied for user 'root'@localhost mysql error 1045返回'找不到'root@127.0.0.1命令

MySQL - ERROR 1045 - Access denied

Ciarans-MacBook-Pro:~ callanmooneys$ mysqld_safe --skip-grant-tables
131105 21:44:41 mysqld_safe Logging to '/usr/local/mysql/data/Ciarans-MacBook-Pro.local.err'.
131105 21:44:41 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
/usr/local/mysql/bin/mysqld_safe: line 129: /usr/local/mysql/data/Ciarans-MacBook-Pro.local.err: Permission denied
/usr/local/mysql/bin/mysqld_safe: line 166: /usr/local/mysql/data/Ciarans-MacBook-Pro.local.err: Permission denied
131105 21:44:41 mysqld_safe mysqld from pid file /usr/local/mysql/data/Ciarans-MacBook-Pro.local.pid ended
/usr/local/mysql/bin/mysqld_safe: line 129: /usr/local/mysql/data/Ciarans-MacBook-Pro.local.err: Permission denied
Ciarans-MacBook-Pro:~ callanmooneys$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Ciarans-MacBook-Pro:~ callanmooneys$

反馈意见。

1 个答案:

答案 0 :(得分:0)

有点令人困惑,但删除了mySQL和所有相关文件,重新安装,设置root密码,登录为 mysql -u root -p(密码) 它运作良好。

网上有很多资源可能令人困惑,对于遇到类似问题的人,我建议在这里使用官方网站:

http://dev.mysql.com/doc/refman/5.1/en/access-denied.html