C:\AppServ\MySQL> mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决方法:

编辑mysql配置文件my.ini(在mysql的安装目录下,我的在D:\phpStudy\MySQL\my.ini),在[mysqld]这个条目下加入 skip-grant-tables 保存退出后重启mysql

1.点击“开始”->“运行”(快捷键Win+R)。

2.停止:输入 net stop mysql

3.启动:输入 net start mysql

这个时候会出现mysql服务无法启动的情况 我的解决方法是:

cmd中输入命令 “tasklist | findstr "mysql" ” ,用于查找mysql的残留进程。果不其然,确实存在mysql的残留进程,难怪一直提示MySQL服务处于正在启动或者停止的状态中,此时要做的就是杀死MySQL进程。之后输入命令 “taskkill /f /t /im mysqld.exe” ,就可以将mysql残留进程全部杀死了,再次输入命令“tasklist| findstr "mysql"”,查看是否还留有有其他的mysql残留进程,如果还有,则继续杀死,直到完全杀死进程为止,如下图所示。

当mysql残留进程全部结束之后,我们就可以正常启动MySQL服务了,如下图所示。需要注意的是此时还是要以管理员的身份进入命令行窗口。

继续重复mysql的停止 ,启动 的操作

这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现 password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为我们不能grant(没有权限)。(以下操作的目录都是在phpStudy\Mysql\bin下完成的

继续按下面的流程走:

1.进入mysql数据库:
mysql> use mysql;
Database changed

2.给root用户设置新密码: 
mysql> update user set password=password("新密码") where user="root";
Query OK, 1 rows affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

3.刷新数据库

mysql> flush privileges;


Query OK, 0 rows affected (0.00 sec)  

4.退出mysql:
mysql> quit;
Bye

第3步:刷新数据库时失败了 但是仍然没有妨碍最后的成功

改好之后,再修改一下my.ini这个文件,把我们刚才加入的 "skip-grant-tables"这行删除,保存退出再重启mysql就可以了。

最后这一步没有执行  因为已经可以了

本文参考https://www.cnblogs.com/m97i/p/7586628.html  真的好用谢谢

mysql Access denied for user root @localhost (using password:YES)错误的更多相关文章

  1. Web项目打成war包部署到tomcat时报MySQL Access denied for user 'root'@'localhost' (using password: YES)错误解决方案

    Web项目使用使用root账号root密码进行部署,通过Eclipse加载到Tomcat服务器可以发布成功,打成war包放到tomcat的webapps目录无法发布成功,报错: jdbc.proper ...

  2. linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案

    linux连接mysql /usr/local/mysql/bin/mysql -uroot -p 输入密码出现Access denied for user 'root'@'localhost'(us ...

  3. Windows系统下MySQL数据库出现Access denied for user 'root'@'localhost' (using password:YES) 错误

    Windows系统下MySQL数据库出现Access denied for user 'root'@'localhost' (using password:YES) 错误,(root密码错误) 处理方 ...

  4. MySql Access denied for user 'root'@'localhost' (using password:YES) 解决方案

    关于昨天下午说的MySQL服务无法启动的问题,解决之后没有进入数据库,就直接关闭了电脑. 今早打开电脑,开始-运行 输入"mysql -uroot -pmyadmin"后出现以下错 ...

  5. MySQL 出现 Access denied for user 'root'@'localhost' (using password: YES) 错误

    登录某台服务器的mysql时候总报错: mysql2/client.rb:58:in `connect': Access denied for user 'root'@'localhost' (usi ...

  6. MySQL在登陆时出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)错误

    错误显示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决方案: 1.找到配 ...

  7. mysql—Access denied for user 'root'@'localhost' (using password:NO)

    安装mysql未设置初始密码,登录提示Access denied for user 'root'@'localhost' (using password:NO): 解决方案:  sudo /etc/i ...

  8. Access denied for user 'root'@'localhost' (using password: NO)错误的解决方案

    在windows下使用PHP连接MYSQL数据库,确定MYSQL的服务已经启动了,而且Workbench也是可以连上去的,但是始终网页测试都提示Access Denied. 最终解决办法: set p ...

  9. mariadb mysql 报'Access denied for user 'root'@'localhost' (using password: NO)'错误的解决

    C:\Program Files\MariaDB 10.2\bin>mysql admin -u root password "x123456789" mysql Ver 1 ...

随机推荐

  1. GDI和内核对象区别

    1.GDI对象和核心对象之间最主要的区别在于GDI对象有单一拥有者,不是进程就是线程 2.核心对象可以有一个以上的拥有者,甚至可以跨进程,为了保持对每一位(拥有者)的追踪,核心对象保持了一个引用计数, ...

  2. SpringBoot整合Apache Shiro权限验证框架

    比较常见的权限框架有两种,一种是Spring Security,另一种是Apache Shiro,两种框架各有优劣,个人感觉Shiro更容易使用,更加灵活,也更符合RABC规则,而且是java官方更推 ...

  3. MODBUS协议解析中常用的转换帮助类(C#)

    p{ text-align:center; } blockquote > p > span{ text-align:center; font-size: 18px; color: #ff0 ...

  4. http协议中的响应代码从 1xx ~ 5xx,一共有41种

    http协议中的响应代码从 1xx ~ 5xx,一共有41种 http://how2j.cn/k/http/http-response-code/572.html

  5. C# 循环时,操作另外一个进程直到操作完成,循环继续执行

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  6. JQuery小知识

    一.禁用鼠标右键 $(document).ready(function() { $(document).bind("contextmenu", function(e) { retu ...

  7. appium工作原理

    Appium原理 面试的时候,被问到appium原理,一点不会,实在尴尬.大家可以直接翻看原作https://blog.csdn.net/jffhy2017/article/details/69220 ...

  8. SQL 连接(内连接,外连接)

    内连接 现在有两张表,学生表student1,成绩表SC1,两张表的数据如下 现在要对两张表做连接查询,连接一般需要写条件,where 或者 on 后面 , select * from student ...

  9. MariaDB xtrabackup物理备份与还原

    xtrabackup物理备份 1.1 安装xtraback 安装依赖: [root@localhost ~]# yum install -y perl-DBD-MySQL perl-DBI perl- ...

  10. IP通信第四周作业

    一.选择交换机的主要技能指标是什么? a.背板带宽.二/三层交换吞吐率. b.VLAN类型和数量. c.交换机端口数量及类型. d.支持网络管理的协议和方法.需要交换机提供更加方便和集中式的管理. e ...