编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

# mysql 8.0 版本无法使用 sqlyog 等图形界面 登录 的解决方法

wxchong 2024-08-27 00:07:07 开源技术 23 ℃ 0 评论

30万以下的理想L6来了 #


# mysql 8.0 版本无法使用 sqlyog 等图形界面 登录 的解决方法


当我们在 cmd 下登录 mysql 时正常时,用 sqlyog 等图形界面 连接数据库时却提示错误。

如下图:



**原因分析**:

无法连接是因为:密码加密方式与 sqlyog 不对应。

**解决方法:**

1、cmd 下登录 mysql, 使用以下命令修改 root 密码:

alter user 'root'@'%' identified with mysql_native_password by '123456';



2、用 sqlyog 等图形界面 ,再次测试连接:



## 3、如果还提示如下错误,



## 4、可以采用以下方法解决:

### 1)首先连接权限数据库:

mysql> use mysql;



### 2)查看 user 主机名:

mysql> select user, host from user;

可以看到 root 用户的 host 是 【%】,而非 localhost



### 3)所以修改密码命令更改为:

mysql> ALTER USER 'root'@'%' IDENTIFIED BY '123';



5、如果还是提示错误,不能修改,可以看下如下方法:

[ mysql 修改密码出现 1396 ERROR 错误 ](https://editor.csdn.net/md/?articleId=137309253)

6、如果想创建新用户,并且更改登录权限,使用 sqlyog 等图形界面 登录 ,

采用如下方法,具体步骤:

-- 登录 mysql 数据库(打开 win+R ==> cmd):

c:\test> mysql -uroot -p密码

-- 创建用户及密码(网络用户):

mysql> create user 'username'@'%' identified by '123456';

-- 创建用户及密码(本地用户):

mysql> create user 'testuser'@'localhost' identified by 'test123';

-- 为新创建的网络用户 username 授予所有权限:

mysql> grant all on *.* to 'username'@'%' with grant option;

-- 为新创建的本地用户 username 授予所有权限:

mysql> grant all on *.* to 'testuser'@'localhost' with grant option;

--- 刷新权限

mysql> flush privileges;

-- 重置密码方式(mysql8.0 以下版本):

mysql> update mysql.user set authentication_string=password(‘123456’) where user=‘root’;

mysql> update mysql.user set authentication_string=password(‘test123’) where user=‘testuser’;

--- 重置密码方式 (mysql8.0 以上版本):

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '012311';

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表