MySQL80数据库报错1045解决方法(navicat报错)

我在这里用到的MySQL可视化工具为Navicat,这个错误是这样说的:1045    Access denied for user 'root'@'localhost' (using password:YES)

这个意思是说:用户“root”@本地主机的访问被拒绝

查了很久,发现新的mysql8.0以上在my.ini下的[mysqlld]添加skip-grant-tables不能让任何用户都能访问数据库。

那么新的数据库怎么办呢?

1、管理员权限下运行cmd,关闭服务   net stop mysql

 2、进入到MySQL安装下bin目录 执行 :mysqld --console --skip-grant-tables --shared-memory能让任何用户都能访问数据库

执行完后无法输入,不要关闭,另外打开一个cmd

3、在新的cmd下运行mysql -u root -p就能免密进入(我这里是自己输入的密码。。。)

 4、运行sql语句

    • use mysql;  使用MySQL数据库
    • update user set authentication_string='' where user='root';  将密码改为空
    • flush privileges;  刷新
    • ALTER user 'root'@'localhost' IDENTIFIED BY '1234';  修改密码1234

参考博客https://blog.csdn.net/qq_27820551/article/details/101488430

原文地址:https://www.cnblogs.com/sonofdemon/p/11723277.html