连接数据库或者在Navicat连接数据库,报错信息为:1045 - Access denied for user 'root'@'localhost' (using password:YES)

连接数据库报错问题

一、报错问题提示信息

1.终端连接报错

# 终端连接报错提示信息

1045 - Access denied for user 'root'@'localhost' (using password:YES)

Navicat连接报错

二、解决方法:

以管理员身份运行cmd;

2.cd到mysql下的bin目录;

C:\Program Files\MySQL\MySQL Server 5.5\bin

cmd

3.停止mysql服务

# window环境 停止mysql服务命令

net stop mysql

# 虚拟机centos环境 停止mysql服务命令

service mysqld stop

4.mysql权限屏蔽

# window环境 停止mysql服务命令

mysqld --skip-grant-table

# 虚拟机centos环境 停止mysql服务命令

mysqld_safe --skip-grant-table

5.重新打开终端(快捷键:win+r)

mysql -u root mysql

6.重置mysql密码

# 重置root用户密码为:test132456

UPDATE user SET Password=PASSWORD(‘test123456’) where USER=‘root’;

重置密码成功

7.更新数据库

# 更新命令

FLUSH PRIVILEGES;

# 删除空user命名

delete from user where USER='';

三、连接数据库

终端连接数据库

# 连接数据库

mysql -u root -p

# 输输入重置的密码test123456

test123456

Navicat连接数据库

精彩内容

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: