mysql链接报错1045:Access denied for user root@localhost解决方法

Posted 敲代码的尼采

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql链接报错1045:Access denied for user root@localhost解决方法相关的知识,希望对你有一定的参考价值。

安装了mysql5,本地连接没有问题,但是通过局域网的其他电脑连接报错1045:Access denied for user root@localhost

网上搜索到的解决方法(亲测可以解决上述问题):

     一:停止MySQL服务

       在mysql的安装目录,输入命令net stop mysql

       二:跳过验证

       在my.ini里面68行(随便选位置)添加    skip_grant_tables 然后保存关闭

     三:重启mysql并登陆mysql

       命令:net start mysql(启动)

          mysql -uroot -pmysql(登陆)

       四:修改密码

       命令:use mysql

          update MySQL.user set authentication_string=password(‘PASSWORD‘) where user=‘root‘;   注:命令中的PASSWORD换成自己需要设置的密码

          flush privileges; 刷新配置

          exit ;(退出服务)

     五:打开my.ini文件,删除刚才添加的最后一行的内容,保存并关闭文件。然后在命令行用net stop mysql和net start mysql重启mysql。然后在命令行窗口,用刚才设置的密码登录mysql。登录成功,问题解决!

       命令:mysql -uroot -p

以上是关于mysql链接报错1045:Access denied for user root@localhost解决方法的主要内容,如果未能解决你的问题,请参考以下文章

用工具软件远程链接数据库时报-1045 access denied错误

navicat报错1045-Access denied for user ‘nova’............如图!求高人解答,小弟感激不尽!!!!

phpadmin登录报错:#1045 - Access denied for user 'root'@'localhost' (using password: yes)

Django链接Mysql 8.0 出现错误(1045:Access denied for user 'root'@'localhost' (using passwor

1045 - Access denied for user ‘root‘@‘localhost‘ (using password: YES)

1045 - Access denied for user ‘root‘@‘localhost‘ (using password: YES)