1、首先进入mysql的安装目录下的bin目录,例如我的是【C:\WINDOWS\System32\cmd.exe】
 
2、接着输入cmd,回车
 
 
3、在命令行中输入命令【mysql -hlocalhost -uroot -p 按回车键,输入密码】,其中【-h主机名 -u用户 -p密码】 
 
4、成功进入界面
...
5、show databases;   查看所有数据库
 

在bin目录下执行mysql -uroot -p123456

登录后执行:

use mysql;

select host, user, plugin from user;

 

打印:

+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

发现新版MySQL都是默认用caching_sha2_password这个plugin来加密密码了,HeidiSQL无法接入。现改成原生密码的加密方式。

 

执行:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

flush privileges;

 

就可以了。再执行上面的查询语句,返回:

+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | mysql_native_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)

可知,已经改mysql_native_password插件了。