############下面是win下面的解决方法#############

遇到MySQL“错误代码#1045 Access denied for user 'root'@'localhost' (using password:YES)” 需要重置root账号权限密码,这个一般还真不好解决。

不过,这几天调试的时候真的遇到了这种问题,不能跳过,必须解决才能在 本地调试程序源码,没办法,一点点解决吧。

好在遇到这种问题的情况,大有人在,所以很多就搬现成的,只要能解决问题就行了。

方法:

第一点,停止mysql服务,CMD打开DOS窗口,输入 "net stop mysql ";不过有时候不停止也是无所谓;

第二点,在CMD命令行窗口,进入MYSQL安装目录 比如“E:\APMServ5.2.6\MySQL5.1\bin”(我用的就是APMServer)

如下图:

第三点,在第二点的命令窗口输入命令为:"mysqld -nt --skip-grant-tables"

如果是linux系统,那么是/etc/mysql/mysql.conf.d/mysqld.cnf的[mysqld]下面加入:

skip-grant-tables(Mysql  5.7.26,linux 18.10,改完后记得service mysql restart)

作用是,进入mysql安全模式,即当mysql起来后,不用输入密码就能进入数据库。

这时候可以进入数据库后,给自己的数据库重新设置密码就可以了!

如果,还是出现1045错误的话,继续执行以下操作

1.重新打开一个CMD命令行窗口,输入:"mysql -uroot -p",使用空密码的方式登录MySQL(不用输入密码,直接按回车)

2.输入以下命令开始修改root用户的密码(注意:命令中"mysql.user"中间有个“点”)

(旧版本mysql)

"mysql>update mysql.user set password=PASSWORD('新密码') where User='root'; "

(新版本mysql)

mysql> update mysql.user set authentication_string = "appleyuchi"  where user = "appleyuchi" ;
mysql> update mysql.user set authentication_string = "appleyuchi"  where user = "root" ;

3.刷新权限表

"mysql>flush privileges"

4.退出 :"mysql>quit "

搞定,功成身退!

#################################################3

下面是ubuntu下面的解决方案:

mysql -udebian-sys-maint -p

然后使用/etc/mysql/debian.cnf中的密码登录

update mysql.user set authentication_string=password('appleyuchi') where user='root';

mysql> GRANT USAGE ON *.* TO 'appleyuchi'@'localhost' IDENTIFIED BY 'appleyuchi' WITH GRANT OPTION;

这了我的用户名和密码都是appleyuchi

mysql> FLUSH PRIVILEGES;

mysql>quit

然后:

mysql u -root -p输入appleyuchi即可登录

参考链接:

http://blog.lykezhan.com/jishu/biji/2017/0319/224.html

错误代码#1045 Access denied for user 'root'@'localhost' (using password:YES)相关推荐

  1. MYSQL错误代码#1045 Access denied for user 'root'@'localhost'

    http://blog.csdn.net/lykezhan/article/details/70880845 遇到MYSQL"错误代码#1045 Access denied for user ...

  2. ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)(转)

    前两天也偶尔出现这个错误,也没在意,因为我重新修改一下mysql的root密码后又可以用了,但昨天却不行,我把root密码修改以后虽然当时能用, 一旦重新进入就都不能用了,可我的密码明明没有错啊?今天 ...

  3. windows mysql提示:1045 access denied for user 'root'@'localhost' using password yes 解决方案

    win7 MySql5.6.17 提示:1045 access denied for user 'root'@'localhost' using password yes 从网上找到的解决方法,以此博 ...

  4. phpmyadmin #1045 - Access denied for user 'root'@'localhost' (using password: NO)

    phpmyadmin访问遇到1045问题 #1045 - Access denied for user 'root'@'localhost' (using password: NO) 解决办法 找到p ...

  5. Django链接Mysql 8.0 出现错误(1045:Access denied for user ‘root‘@‘localhost‘ (using password: NO) 的一种解决方法

    Django链接Mysql 8.0 出现错误(1045:Access denied for user 'root'@'localhost' (using password: NO) 的一种解决方法 参 ...

  6. MySQL备份报错mysqldump: Got error: 1045: Access denied for user ‘root‘@‘localhost‘ (using password: YES)

    MySQL备份报错mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) ...

  7. Error:1045, Access denied for user 'root'@'localhost' (using password: YES) (Phon3.6+Mysql8.1 )

    哇,闹了一个大乌龙,昨天,写了个脚本给之前移植的mysql添加数据,结果一个小问题困了我0.75天. 脚本代码如下:(期间有个小插曲,我把port="3306",报错了,但是很快排 ...

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

    MYSQL 1045 - Access denied for user 'root'@'localhost' (using password: YES) 1.停止mysql服务 cmd打开终端 net ...

  9. mysql8.0 【1045 - Access denied for user ‘root‘@‘localhost‘(using password: YES)】报错

    在项目中连接mysql8.0出现 [1045 - Access denied for user 'root'@'localhost'(using password: YES)]报错 1.在cmd下启动 ...

最新文章

  1. 快速排序(C++版)
  2. flink网页端提交pr-修改文档报错
  3. 初学Linux之程序安装
  4. Mysql 数据库水平分表 存储过程
  5. php 并发 100 压测,简单PHP把握站点并发数
  6. 信息学奥赛C++语言: 数字方阵
  7. ERP项目实施记录01
  8. git小乌龟不显示图标状态解决方案
  9. 智能计算系统(学习笔记)-第三章深度学习
  10. JAVA强制删除文件file
  11. 软件测试车载系统,车载软件测试
  12. ps哪个版本自带Camera Raw插件,怎么开启?
  13. VBA-使用inputbox方法
  14. 马哥教育SRE笔记【作业】week02
  15. mac 阿里云ecs配置php,在Mac OS下配置PHP开发环境
  16. 区间贪心:最小区间覆盖问题、PIPI的高速公路
  17. 互联网地图栅格比例尺(3857,4326)
  18. U-BOOT启动流程【03】
  19. 01:高斯噪声和椒盐噪声
  20. 支持免费试用的香港云服务器推荐

热门文章

  1. “数据分析”如何作用于“用户研究”?--转载微博
  2. 【JAVASCRIPT】表单序列化问题
  3. greenplum配置高可用_Greenplum 的高可用是怎么做到的?
  4. react16中ref的使用
  5. OpenCv:椭圆上点的计算方程
  6. DNN:逻辑回归与 SoftMax 回归方法
  7. java实现网站错别字搜索对的结果_Java问题:根据输入的关键词查询出搜索结果,再将搜索结果中的关键词用红色显示?这个怎么实现?...
  8. Lnmp搭建zabbix运维监控系统
  9. python对象继承
  10. BZOJ 2733 线段树的合并 并查集