是的,另一个MySql:ERROR 1045(28000):拒绝访问用户'root'@'localhost'(使用密码:YES)

aal*_*002 2 ruby mysql ruby-on-rails

所以我不确定是什么原因造成我的MySql密码加密(升级到Mountain Lion,重新安装ruby/rails(其他问题),或者只是运气不好)但是我们在这里:

登录到mysql很好,但我无法登录到root

Ayman$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 96
Server version: 5.5.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Run Code Online (Sandbox Code Playgroud)

当我尝试登录root时:

Ayman$ mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Run Code Online (Sandbox Code Playgroud)

看着用户:

mysql> CREATE USER root@localhost IDENTIFIED BY 'out22out';
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s)     for this operation
mysql> SELECT USER(),CURRENT_USER();
+-----------------+----------------+
| USER()          | CURRENT_USER() |
+-----------------+----------------+
| Ayman@localhost | @localhost     |
+-----------------+----------------+
1 row in set (0.00 sec)

mysql> SELECT USER, HOST FROM mysql.user;
ERROR 1142 (42000): SELECT command denied to user ''@'localhost' for table 'user'
mysql> select user, host from mysql.user;
ERROR 1142 (42000): SELECT command denied to user ''@'localhost' for table 'user'
mysql> grant all on *.* to Ayman@'%';
ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO)
mysql> 
Run Code Online (Sandbox Code Playgroud)

我已经尝试重新安装MySql(不确定如何卸载它),停止服务器实例并重新启动它,以及关于右侧无数类似问题的所有其他建议.我已经在这3天了,这让我很伤心.

任何线索?

Mar*_*c B 5

您可以启动MySQL(服务器,而不是命令行监视器)--skip-grant-tables,这会暂时关闭权限系统.这将让你进入,更新你的帐户/密码,而没有那些搞砸了权限阻碍.修复问题后,您flush privileges;可以重新启用权限系统.