简体   繁体   English

Mysql 错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

[英]Mysql error: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

This is driving me crazy...when I try to login to Mysql.这让我发疯...当我尝试登录到 Mysql 时。

user-MacBook:~ user$ cd /usr/local/mysql/bin
user-MacBook:bin user$ ./mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
user-MacBook:bin user$ ./mysql
ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: NO)

Someone would help?有人会帮忙吗? Thankyou!!谢谢!!

I think, You have input wrong password... In my case, representing like this if i have put wrong passwd.我想,你输入了错误的密码......在我的情况下,如果我输入了错误的密码,就像这样表示。

jonghan@jonghan-MS-7817:~$ /usr/bin/mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

In second case is same issue.在第二种情况下是同样的问题。

If you have forgotten your password, i recommend to reset your mysql root password.如果您忘记了密码,我建议您重置您的 mysql root 密码。

First of all, you have to stop mysql service.首先,你必须停止mysql服务。

#sudo service mysql stop

Second, Add 'skip-grant-tables' in your my.conf or my.cnf file.其次,在 my.conf 或 my.cnf 文件中添加“skip-grant-tables”。

In my case (MySQL v5.7.17), mysqld.cnf is in the '/etc/mysql/mysql.conf.d'.就我而言(MySQL v5.7.17),mysqld.cnf 位于“/etc/mysql/mysql.conf.d”中。

Almost my.conf / my.cnf file shows like this.几乎 my.conf/my.cnf 文件是这样显示的。

[mysqld]
user         = mysql
pid-file     = /var/run/mysqld/mysqld.pid
socket       = /var/run/mysqld/mysqld.sock
port         = 3306
basedir      = /usr
datadir      = /var/lib/mysql
tmpdir       = /tmp
lc-messages-dir = /usr/share/mysql

skip-external-locking

skip-grant-tables         /*** You Add this code! ***/

Next, restart mysql service.接下来,重启mysql服务。

#sudo service mysql start

And, open your mysql service.并且,打开你的 mysql 服务。 In your case,在你的情况下,

$ cd /usr/local/mysql/bin
$ ./mysql -u root

Then, You can login without authenticate.然后,您无需身份验证即可登录。

Next, You should change password for 'root'.接下来,您应该更改“root”的密码。

mysql> UPDATE user SET password=PASSWORD('yourpassword') WHERE user='root';

After All, restore my.conf / my.cnf / mysqld.cnf and so on.毕竟恢复my.conf/my.cnf/mysqld.cnf等。 (Delete 'skip-grant-tables') (删除'skip-grant-tables')

Finally, restart mysql service.最后重启mysql服务。

$ sudo service mysql restart

If you cannot access mysql though following these steps, i recommend to Re-setup Mysql.如果按照这些步骤仍然无法访问 mysql,我建议您重新设置 Mysql。

Thanks!谢谢!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法访问 MySQL:错误 1045 (28000):用户 'root'@'localhost' 的访问被拒绝(使用密码:是) - Cannot access MySQL : ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 错误 1045 (28000):通过 Python 连接到 MySQL 时,用户 'root'@'localhost'(使用密码:YES)的访问被拒绝 - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) when connecting to MySQL through Python [root @ localhost〜]#mysql -u root -p输入密码:错误1045(28000):用户'root'@'localhost'的访问被拒绝(使用密码:是) - [root@localhost ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) ERROR 1045 (28000): 用户 'root'@'localhost' 访问被拒绝(使用密码:YES); 无法重设密码 - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES); Can't reset password 错误 1045 (28000): 用户 'root'@'localhost' 访问被拒绝(使用密码:YES)-Ubuntu - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) -Ubuntu 错误1045(28000):在Linux 16.04上对用户'root'@'localhost'的访问被拒绝(使用密码:是) - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) on linux 16.04 错误 1045 (28000):Ubuntu(Zorin OS)上的用户 'root'@'localhost'(使用密码:YES)的访问被拒绝 - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) on Ubuntu (Zorin OS) 错误1045(28000):用户'= root'@'localhost'的访问被拒绝(使用密码:否) - ERROR 1045 (28000): Access denied for user '=root'@'localhost' (using password: NO) ERROR 1045(28000):用户'root'@'localhost'拒绝访问(使用密码:NO) - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 错误1045(28000)访问被拒绝用户'root'@'localhost'(使用密码:YES) - error 1045 (28000) access denied for user 'root'@'localhost' (using password: YES)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM