linux下mysql登录报错“Access denied for user 'root'@'localhost' (using password: YES”)的处理方法
最近登录某台服务器的mysql时候总报错:
Access[root@log01 ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) denied for user 'root'@'localhost' (using password: NO)
我猜想是不是密码忘记了。。。然后准备修改密码:
#mysqladmin -u root -p password 123456 ###设置root密码为123456
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
依然报这个错误。。。蛋疼了,百度一下,最终找到了方法如下:
方法一:
# /etc/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
Enter password: <输入[client]节的密码>
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>
方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!
# mysql -uroot -p
Enter password: <输入/etc/mysql/debian.cnf文件中[client]节提供的密码>
至此,困惑多时的问题解决了!
linux下mysql登录报错“Access denied for user 'root'@'localhost' (using password: YES”)的处理方法的更多相关文章
- mysql登录报错“Access denied for user 'root'@'localhost' (using password: YES”)的处理方法
环境 CentosOS 6.5 ,已安装mysql 情景 root密码忘记,使用普通用户无法登录 解决 问题一 无法使用mysql命令 参考文章:https://www.cnblogs.com/com ...
- 最新 mysql登录报错“Access denied for user 'root'@'localhost' (using password: NO”的处理方法
1.关闭正在运行的MySQL.2.打开DOS窗口,转到mysql\bin目录.3.输入mysqld --skip-grant-tables回车.如果没有出现提示信息,那就对了.(正常的情况是光标闪烁没 ...
- mysql登录报错“Access denied for user 'root'@'localhost' (using password: YES”的处理方法
使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码: 文件内容: [client]host = localhostuser = debian-sys-maint ...
- MySQL登录报错"Access denied for user 'root'@'localhost' (using password: YES)"
最近登录MySQL时候总报错: # mysql -uroot -p Enter password: ERROR (): Access denied for user 'root'@'localhost ...
- 关于Linux下面msyql安装后并未设置初始密码,但是登录报错“Access denied for user 'root'@'localhost' (using password: NO)”的解决方案
如上图:首先我安装mysql的时候并没有设置密码,但是就是登不进去,百度了一下,解决方案如下: 解决方案地址:http://zhidao.baidu.com/link?url=7QvuOKtfRdMT ...
- 在MySQL登录时出现Access denied for user 'root'@'localhost' (using password: YES) 拒绝访问,并可修改MySQL密码
这两天装了一个mysql 5.7数据库,但是在本地dos登陆不上去,报错Access denied for user 'root'@'localhost'(using password:YES): 也 ...
- 【转载】在MySQL登录时出现Access denied for user 'root'@'localhost' (using password: YES) 拒绝访问,并可修改MySQL密码
在MySQL登录时出现Access denied for user 'root'@'localhost' (using password: YES) 拒绝访问,并可修改MySQL密码 2018年08月 ...
- 008-MySQL报错-Access denied for user 'root'@'localhost' (using password: NO)
1.新安装的mysql报错 MySQL报错-Access denied for user 'root'@'localhost' (using password: NO) 解决方案 1.先停掉原来的服务 ...
- 连接数据库报错Access denied for user 'root'@'localhost' (using password:YES)
报错信息为:pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using pa ...
随机推荐
- Java练习题02
问题: 编程求一个整数数组的最大值.最小值.平均值和所有元素的和. 代码: public class Page99{ public static void main(String args[] ...
- mysql查询-从表1中查询出来的结果重新插入到表1
原有表结构 CREATE TABLE `t_card_user` ( `id` varchar(32) NOT NULL, `card_user_id` bigint(20) DEFAULT NULL ...
- C# 创建目录
C#创建目录 var strpatj = HttpRuntime.AppDomainAppPath; if (!Directory.Exists(strpatj+"\\temp") ...
- 骑芯供应链(T 面试)
1.目前市面上主流的团队开发模式是什么? 正解:DevOps,https://blog.csdn.net/bntX2jSQfEHy7/article/details/79168865 2.你觉得什么是 ...
- 7-Java-C(四平方和)
题目描述: 四平方和定理,又称为拉格朗日定理: 每个正整数都可以表示为至多4个正整数的平方和. 如果把0包括进去,就正好可以表示为4个数的平方和. 比如: 5 = 0^2 + 0^2 + 1^2 + ...
- String系列之replaceAll方法替换.
直接使用String类的replaceall方法的第一个参数并不是简单的字符串,而是一个正则表达式.在正则表达式中,英文点号(.)表示任意字符,所以你原先的写法会把所有字符都替换成空白. 转义使用所以 ...
- Java中wait()方法为什么要放在同步块中?(lost wake-up 问题)
问题起源 事情得从一个多线程编程里面臭名昭著的问题"Lost wake-up problem"说起. 这个问题并不是说只在Java语言中会出现,而是会在所有的多线程环境下出现. 假 ...
- <c:forEach>实例演示
<c:forEach>实例演示 <%@ page language="java" contentType="text/html; charset=UTF ...
- mysql时间的处理
mysql中格式化时间为: 1,DATE_FORMAT(APPLYDATE,'%Y-%m-%d %H:%i:%S') AS APPLYDATE 2,DATE_FORMAT(CHKSIGNDATE, ' ...
- SCOI2013 数数
题目描述 题解: 很玄学的一道数位$dp$,看了很多篇题解才懂. 直接挂$l$的题解. 代码: #include<cstdio> #include<cstring> #incl ...