解决mysql-8.0.18 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

由于mysql版本的更新,当遇到这个问题时在网上搜索的很多方法并不完全使用,因此记录当前解决mysql-8.0.18  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)的方法。

解决方案:

1. 快捷键 windows + R     ;输入 services.msc  ;   找到MySQL  停止其服务

2. 在命令行程序中;注意需要以管理员权限运行cmd程序,不然无法关闭mysqld进程

>>tasklist |findstr mysqld        这行命令可以用来查看mysqld是否在运行,在运行中则可以查到它的PID

>>taskkill /F /PID xxxx             xxxx是从前面一条命令得到的PID值

3.跳过权限登录MySQL 服务器端

在cmd中执行  mysqld --console --skip-grant-tables --shared-memory

此时cmd程序会阻塞,关闭cmd程序 然后重新以管理员权限运行cmd

然后在cmd命令行中输入 mysql 就能连接上MySQL 服务器端了

4.无密码登录

mysql -u root -p 
   按 enter键 进入

5.修改密码

use mysql;
    select user,host,authentication_string from user;
    ### 密码设置为空
    update user set authentication_string='' where user='root';

     flush privileges;
     quit;

猜你喜欢

转载自www.cnblogs.com/blzm742624643/p/12130186.html