mysql @'localhost'_安装mysql8.0报错:Access denied for user 'root'@'localhost'

报错信息: E:\developsoftware\mysql-8.0.13-winx64\bin>mysql -uroot -p Enter password: ****** ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) E:\developsoftware\mysql-8.0.13-winx64\bin>mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

报错原因:注意前提,cmd窗口必须以管理员的身份启动!!

1.我在安装mysql8.0的时候用以下的命令进行的初始化。 E:\developsoftware\mysql-8.0.13-winx64\bin>mysqld --initialize-insecure //用这个命令去做初始化,代表的就是mysql的免密登录。 //而我当时在安装成功后又给它设置了密码,这就导致了一个问题,在连接mysql的时候由于设置了密码,如果不填则会报错; //如果你填了并且填的跟你设置的是一样的他也会报错,因为你的初始化时用的是免密连接。这样他就出现个死结。。。

[Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

解决方法:

1.在初始化的时候使用下面命令,设置默认初始密码: E:\developsoftware\mysql-8.0.13-winx64\bin>mysqld --initialize //这个命令会在安装mysql的时候默认给设置一个密码,当然这个密码不是很好记住, //等后来自己再重新设置一下就行(但是以后连接就需要密码,而不能免密)。

2.将密码设置为空(即不设置密码)。

既然这时候不管有没有密码都不能登入mysql了,那么我们就得想办法先登入进去才能够去将密码设置为空,下面来说跳过权限验证启动mysql服务。 //无需密码启动服务 C:\windows\system32>e: E:\>cd developsoftware\mysql-8.0.13-winx64\bin E:\developsoftware\mysql-8.0.13-winx64\bin>net stop mysql MySQL 服务正在停止. MySQL 服务已成功停止。 E:\developsoftware\mysql-8.0.13-winx64\bin>mysqld --console --skip-grant-tables --shared-memory 2018-12-04T10:47:24.833692Z 0 [System] [MY-010116] [Server] E:\developsoftware\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) starting as process 11548 2018-12-04T10:47:24.835921Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2018-12-04T10:47:33.022212Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2018-12-04T10:47:33.158126Z 0 [System] [MY-010931] [Server] E:\developsoftware\mysql-8.0.13-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.13' socket: '' port: 0 MySQL Community Server - GPL. 2018-12-04T10:47:33.317040Z 0 [Warning] [MY-011311] [Server] Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible' //重新以管理员身份打开一个cmd窗口,启动mysql服务,然后在修改 E:\developsoftware\mysql-8.0.13-winx64\bin>mysql.exe -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.13 MySQL Community Server - GPL Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

mysql> use mysql Database changed mysql> update user set authentication_string='' where user='root'; Query OK, 1 row affected (0.39 sec) mysql> flush privileges Query OK, 0 rows affected (0.10 sec)

若有问题欢迎大家与我互动交流,如果文章帮到了你,请点小手指。另外,每周我会尽量至少更新一篇博客文章,喜欢的朋友可以加一下关注。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值