声明:全文均摘抄于MySQL ERROR 1698 (28000) 错误

    //错误起源:
~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

解决步骤:

  1. 停止mysql服务
    ~$ sudo service mysql stop
  1. 以安全模式启动MySQL
    ~$ sudo mysqld_safe --skip-grant-tables &
  1. 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)
  1. 查看一下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)
  1. 关于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)
  1. 重启服务,问题就解决了
    ~$ 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)

7.linux云主机端:开启远程连接

    sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address = 127.0.0.1
sudo service mysql restart

数据库之MySQL ERROR 1698 (28000) 错误:Access denied for user 'root'@'localhost'" error【摘抄】的更多相关文章

  1. CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

    连接mysql出错:CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for u ...

  2. mysql 创建帐号出现 Access denied for user 'root'@'localhost'错误(转载)

    从供应商那边接手一个MySQL数据库(数据库版本为5.7.21 MySQL Community Server (GPL)),在创建账号时遇到了“ERROR 1044 (42000): Access d ...

  3. phpMyAdmin出现错误 Access denied for user 'root'@'localhost' (using password: NO)

    今天安装wmpp,之后启动后点击phpMyAdmin 报拒绝连接错误:#1045 - Access denied for user 'root'@'localhost' (using password ...

  4. eclipse不正常编译导致错误:Access denied for user 'root'@'localhost' (using password: YES)

    使用eclipse连接mysql报错:Access denied for user 'root'@'localhost' (using password: YES) 连接代码没有任何问题,网上找了很多 ...

  5. 解决:MySQL 报错:1045 - Access denied for user 'root'@'localhost'(using password YES)

    一.前言 今年疯狂迷上了开源,只要看到好的开源项目,就会不顾一切一股脑扎进去研究,五一期间发现一个很好的关于众筹的开源项目,但不巧,这个项目竟然是 PHP 写的,没学过 PHP,自然对这个开源项目毫无 ...

  6. Windows下重置MySQL密码(最开始是因为Access denied for user 'root'@'localhost'这个原因,无法登陆 'root'@'localhost')

    本人使用的MySQL5.5,其他版本未测试过. 方法一: 更改密码: mysql -u root -p Enter password:*** mysql>use mysql; 选择数据库 Dat ...

  7. mysql 8.x 登陆提示 Access denied for user 'root'@'localhost' (using password: YES)

    第一步:修改 /etc/mysql/my.cnf. 在[mysql]下添加skip-grant-table:重启. 第二步:通过mysql命令登陆: flush privileges; use mys ...

  8. mysql (已解决)Access denied for user 'root'@'localhost' (using password: NO)

    找到mysql中的my.ini,在最后一行加入 skip-grant-tables 在“管理工具”-”服务” 中重启mysql 解决问题

  9. 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 ...

随机推荐

  1. html 佈局

    html常見佈局方式有以下幾種: 1.使用div的html 利用div可以為html實現多列佈局. 2.使用html5的網站佈局, 利用html新增的header.footer.nav.section ...

  2. entity framework 缓存干扰的数据不一致问题

    本来EF的设计上DbContext就应该是一个短暂存在的对象,所以它默认才开了缓存和自动检测对象修改之类的功能,而且不是线程安全的.理想的生命周期应该是处理一次请求使用一个context,全局使用会带 ...

  3. fopen

    转自http://blog.sina.com.cn/s/blog_4b986f1a0101349k.html matlab中fopen函数在指定文件打开的实例如下: *1)“fopen”打开文件,赋予 ...

  4. SESSION和cookie的使用和区别

    PHP中SESSION和cookie的使用和区别 cookie 是一种在远程浏览器端储存数据并以此来跟踪和识别用户的机制. PHP在http协议的头信息里发送cookie, 因此 setcookie( ...

  5. BZOJ2135 刷题计划(贪心+二分)

    相邻数作差后容易转化成将这些数最多再切m刀能获得的最小偏差值.大胆猜想化一波式子可以发现将一个数平均分是最优的.并且划分次数越多能获得的偏差值增量越小.那么就可以贪心了:将所有差扔进堆里,每次取出增量 ...

  6. Codeforces Round #431 (Div. 2) B. Tell Your World

    B. Tell Your World time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  7. Stack Overflow:研究发现访问PHP和 Android的流量更可能来自低收入国家

    Stack Overflow 的数据科学家  David Robinson 发现,软件行业的分工让不同发达地区的程序员依赖于不同的编程语言.软件已经是一个全球性的行业,也有高端低端之分,最高端的是数据 ...

  8. Leetcode 283.移动零 By Python

    思路 我们可以用python的list comprehension来取出所以非0的元素,而且这样取出来会保持原有的相对顺序,再统计先后变化的长度,补上相应的0即可 代码 class Solution( ...

  9. luogu4187 [USACO18JAN]Stamp Painting (dp)

    可以发现,只要存在连续k个相同的,这个情况就一定是合法情况 然而这个不太好算,我们算不存在k个相同的,然后用$m^n$把它减掉 设f[i]为前i个,没有连续k个的 显然$f[i]=m^i ,i< ...

  10. jquery&bootstrap

    学会了用bootstarp和jquery的引用,布局就简单多了,但就是不怎么自由,必须按照固定的来: 引用文件: <script type="text/javascript" ...