mysql登陆ERROR 1045 (28000): Access denied for user

Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

报错信息显示useing passowrd:YES 说明密码是对的,但是拒绝用户root登陆
找到mysql配置文件进行修改

添加skip-grant-tables表示跳过密码验证登陆
然后重启mysql服务

systemctl restart mariadb.service

然后跳过密码登陆mysql:

mysql -uroot -p
Enter password: 不用输入密码

然后进入mysql数据库进行修改root密码:

MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set password=password("000000") where user="root";
MariaDB [mysql]> flush privileges; //刷新权限表
MariaDB [mysql]> quit

把修改my.conf配置文件把刚才配置的skip-grant-tables去掉
然后重启mysql服务验证密码登陆:

systemctl restart mariadb.service
mysql -uroot -p000000
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.17-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

OK,成功登陆进来。

转载于:https://blog.51cto.com/9103824/2373392

你可能感兴趣的:(mysql登陆ERROR 1045 (28000): Access denied for user)