找到my.ini文件(可通过文件搜索框搜索)
我的my.ini文件在C:\ProgramData\MySQL\MySQL Server 8.0
可直接复制路径定位到对应文件夹
对my.ini文件进行修改,修改如下图所示:
# The default authentication plugin to be used when connecting to the server
#default_authentication_plugin=caching_sha2_password
default_authentication_plugin=mysql_native_password
然后打开MYSQL命令行窗口,输入mysql数据库root用户密码后进入,
输入命令:ALTER USER'root'@localhost IDENTIFIED WITH mysql_native_password BY '改为你的密码';
最后搜索服务,重启mysql服务,这样就可以成功连接数据库了!