Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

MySQL 连接错误,使用Navicat连接MySQL出现错误:1045 Access denied for user 'root'@'localhost' (using password: YES)

Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

解决方案:

1.编辑mysql配置文件my.ini

 

在mysql的安装目录下

Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

,在[mysqld]这个条目下加入 skip-grant-tables 保存退出后重启mysql

[mysqld]
#作用是跳过登录的验证
#skip-grant-tables
port = 3306
basedir=C:\\softwaretool\\mysql-5.7.23-winx64
datadir=C:\\softwaretool\\mysql-5.7.23-winx64\\data 
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
max_allowed_packet = 20M
[mysql]
default-character-set=utf8

2.重启mysql

在计算机-管理-服务里面找到MySQL的服务,如图

Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

 

这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现 password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为没有grant权限。

Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

3.进入mysql数据库,给root用户设置密码

 

mysql> use mysql; 
mysql> update mysql.user set authentication_string=password('密码') where user='root' ;

 

Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

4.刷新数据库,并退出

 

mysql> flush privileges;
mysql> quit; 

 

Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

5.修改my.ini文件

改好之后,再修改一下my.ini这个文件,把我们刚才加入的 "skip-grant-tables"这行删除,保存退出再重启mysql服务,再重新用Navicat连接就可以了。

[mysqld]
#作用是跳过登录的验证
#skip-grant-tables
port = 3306
basedir=C:\\softwaretool\\mysql-5.7.23-winx64
datadir=C:\\softwaretool\\mysql-5.7.23-winx64\\data 
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
max_allowed_packet = 20M
[mysql]
default-character-set=utf8

Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YE

 

上一篇:Scala-思维导图


下一篇:Laravel [1045] 解决方法 Access denied for user 'homestead'@'localhost'