MySQL问题:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pas

问题描述:

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

解决方案:

1、跳过权限登录MySQL

root@tencent:~# sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

末尾添加:skip-grant-tables
root@tencent:~# systemctl restart mysql.service
2、通过命令mysql无密码登录

3、修改密码为空

mysql> use mysql; 

mysql> update user set authentication_string='' where user='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

4、恢复步骤1修改,然后重启MySQL服务

5、修改root密码

mysql> use mysql;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Admin@9000';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> exit

 

上一篇:113资讯网:安装程序进入Admin后台出现:SQLSTATE[HY000] [1045] Access denied for user'root'@'localhost


下一篇:Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ''@'localhost' (using