ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决方法
之前MySQL服务端本机上使用密码登陆root账号是没有问题的,但是今天不知道是因为动了哪里,登陆失败并有这个错误代码:
~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
解决步骤:
停止mysql服务
~$ sudo service mysql stop
以安全模式启动MySQL
~$ sudo mysqld_safe --skip-grant-tables &
MySQL启动之后就可以不用密码登陆了
~$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)
查看一下user表,错误的起因就是在这里, root的plugin被修改成了auth_socket,用密码登陆的plugin应该是mysql_native_password。
mysql> select user, plugin from mysql.user;
+-----------+-----------------------+
| user | plugin |
+-----------+-----------------------+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| dev | mysql_native_password |
+-----------+-----------------------+
3 rows in set (0.01 sec)
关于auth_socket,在官方有说明: https://dev.mysql.com/doc/mysql-security-excerpt/5.5/en/socket-authentication-plugin.html ,反正现在暂时不用它, 那就把这里改了。
mysql> update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
重启服务,问题就解决了

~$ sudo service mysql stop
...
* MySQL Community Server 5.7.10 is stopped
~$ sudo service mysql start
..
* MySQL Community Server 5.7.10 is started
~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)

ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决方法的更多相关文章
- Ubuntu16.04 ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决流程
mysql版本 5.7.22 安装完成后出现问题 ERROR 1698 (28000): Access denied for user 'root'@'localhost' 可能是因为初始密码为空:按 ...
- mysql安装以后无法登陆的的解决方法((ERROR 1698 (28000): Access denied for user 'root'@'localhost'))
mysql安装以后无法登陆的的解决方法((ERROR 1698 (28000): Access denied for user 'root'@'localhost')) 解决步骤: [====> ...
- Ubuntu下使用mysqli-connect连接mysql时报错:ERROR 1698 (28000): Access denied for user 'root'@'localhost'
LNMP安装好后,写了个index.php文件,里面的内容很简单,就是想测试php与mysql的通信是否正常,代码如下: <?php $host = 'localhost'; $user = ' ...
- MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost'解决
MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost'解决: # /etc/init.d/mysql stop # my ...
- MySQL使用普通用户访问返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'
这个问题最开始查资料都说要改密码,密码不对.其实不是这个样子都. 解决方法 修改/etc/mysql/my.cnf,添加以下内容 [mysqld] skip-grant-tables 重启mysql服 ...
- ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Some systems like Ubuntu, mysql is using by default the UNIX auth_socket plugin. Basically means tha ...
- MySQL ERROR 1698 (28000): Access denied for user 'root'@'localhost'
今天在安装MySQL的过程中竟然没有让我输入密码,登录的时候也不需要密码就能进入,这让我很困惑. 进了数据库就设置密码,用了各种方式都不行. 虽然我这数据库没啥东西但也不能没有密码就裸奔啊,有点丢人是 ...
- ubuntu下 mysql安装以后无法登陆的的解决方法((ERROR 1698 (28000): Access denied for user 'root'@'localhost'))
1. 删除mysql sudo apt-get autoremove --purge mysql-server-5.0 sudo apt-get remove mysql-server sudo ap ...
- Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
案例环境: 操作系统 :Red Hat Enterprise Linux Server release 5.7 (Tikanga) 64 bit 数据库版本 : Mysql 5.6.19 64 bit ...
随机推荐
- PPAS的MTK tool 工具使用说明
磨砺技术珠矶,践行数据之道,追求卓越价值 回到上一级页面: PostgreSQL基础知识与基本操作索引页 回到顶级页面:PostgreSQL索引页 [作者 高健@博客园 luckyjackg ...
- 【转载】COM 组件设计与应用(三)——数据类型
原文:http://vckbase.com/index.php/wv/1206.html COM 组件设计与应用 系列文章:http://vckbase.com/index.php/piwz?& ...
- 一维码Codabar简介及其解码实现(zxing-cpp)
一维码Codabar:由4条黑色线条,3条白色线条,合计7条线条所组成,每一个字元与字元之间有一间隙Gap做区隔. 条形码Codabar包含21个字元: (1).10个数字0~9; (2)." ...
- 4516: [Sdoi2016]生成魔咒
4516: [Sdoi2016]生成魔咒 链接 题意: 求本质不同的子串. 分析: 后缀数组或者SAM都可以. 考虑SAM中每个点的可以表示的子串是一个区间min(S)~max(S),把每个点的这个区 ...
- [FJOI2015]火星商店问题
[FJOI2015]火星商店问题 神仙线段树分治...不过我不会. 这题用线段树套可持久化Trie还是能写的. 常数有点大,洛谷垫底水平. // luogu-judger-enable-o2 #inc ...
- browser-sync 文件监听失败的解决方案
问题 为了方便实时预览前端开发过程中修改源码后的页面,我在全球最大的同性交友网Github中找到了一个非常实用的工具,browser-sync. 安装使用方式请自行到官网https://browser ...
- 一款好看的Sublime Text浅色主题:Ayu大作
上一篇分享的VS Code的文中,界面也是浅色主题,也是Ayu作品.下面看一下Sublime Text中的Ayu浅色主题 不错吧. 如何下载? 首选项——插件控制——安装插件或者ctrl+shift+ ...
- 粒子群算法(PSO)关于参数w的一些改进方法
(一)线性递减 function [xm,fv] = PSO_lin(fitness,N,c1,c2,wmax,wmin,M,D) format long; % fitness学习函数 % c1学习因 ...
- Spring Boot 学习目录
之前一直做.net 的开发,后来发现C# 在生态方面和Java还是差了好多,而且目前有很多.net 方面的技术也是借鉴了Java相关的开发,所以最近准备学习了解一下java 相关的web开发,从中学习 ...
- iOS 动态库、静态库 . framework 总结(2017.1.25 修改)
修改于2017.1.25 使用Xcode Version 8.2.1 1.怎么创建.framework? 打开Xcode, 选择File ----> New ---> Project 选择 ...