用root用户连接MySQL 数据库报"ERROR 1698 : Access denied for user ‘root’@‘localhost’" 错误。

**客户端:**terminal,Navicat,连接都该错误报错误.

**系统环境:**ubuntu 18,MySQL5.7

**原因:**The reason is that recent Ubuntu installation (maybe others also), mysql is using by default the UNIX auth_socket plugin.

Basically means that: db_users using it, will be “auth” by the system user credentias. You can see if your root user is set up like this by doing the following: $ sudo mysql -u root # I had to use “sudo” since is new installation

mysql> USE mysql;

mysql> SELECT User, Host, plugin FROM mysql.user;

±-----------------±----------------------+

| User | plugin |

±-----------------±----------------------+

| root | auth_socket |

| mysql.sys | mysql_native_password |

| debian-sys-maint | mysql_native_password

±-----------------±----------------------+

As you can see in the query, the root user is using the auth_socket plugin

There are 2 ways to solve this:

You can set the root user to use the mysql_native_password plugin

You can create a new db_user with you system_user (recommended)

Option 1: $ sudo mysql -u root # I had to use “sudo” since is new installation

mysql> USE mysql;

mysql> UPDATE user SET plugin=‘mysql_native_password’ WHERE User=‘root’;

mysql> FLUSH PRIVILEGES;

mysql> exit;

$ service mysql restart

Option 2: (replace YOUR_SYSTEM_USER with the username you have) $ sudo mysql -u root # I had to use “sudo” since is new installation

mysql> USE mysql;

mysql> CREATE USER ‘YOUR_SYSTEM_USER’@‘localhost’ IDENTIFIED BY ‘’;

mysql> GRANT ALL PRIVILEGES ON . TO ‘YOUR_SYSTEM_USER’@‘localhost’;

mysql> UPDATE user SET plugin=‘auth_socket’ WHERE User=‘YOUR_SYSTEM_USER’;

mysql> FLUSH PRIVILEGES;

mysql> exit;

$ service mysql restart

Remember that if you use option #2 you’ll have to connect to mysql as your system username (mysql -u YOUR_SYSTEM_USER)

Note: On some systems (e.g., Debian stretch) ‘auth_socket’ plugin is called ‘unix_socket’, so the corresponding SQL command should be: UPDATE user SET plugin=‘unix_socket’ WHERE User=‘YOUR_SYSTEM_USER’;

mysql 1698_MySQL-1698 : Access denied for user 'root'@'localhost'解决方法相关推荐

  1. ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘解决方法

    事情起源 前天晚上好好的,第二天打开电脑正要开始写垃圾代码时,发现项目启动报错了,看了一下,发现是数据库连不上,我一脸懵逼,只能上csdn搜索大佬的文章,最后解决了问题.下面的过程是本人执行大佬教程时 ...

  2. mysql ERROR 1045 access denied for user 'root'@'localhost' using

    操作系统:WINDOWS7 系统 数据库版本:mysql 5.1 提示:mysql ERROR 1045   access denied for user 'root'@'localhost' usi ...

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

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

  4. MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES) windows下的解决方案(忘记密码)

    MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES) windows下的解决方案(忘记密码) 1.进入管 ...

  5. Access denied for user 'root'@'localhost' 解决流程

    2019独角兽企业重金招聘Python工程师标准>>> ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解 ...

  6. MySQL安装错误——Access denied for user 'root'@'localhost' (using password: YES)

    错误: [root@VM_205_38_centos home]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied ...

  7. 解决ubuntu首次安装Mysql之后,首次登录出现ERROR 1698 (28000): Access denied for user 'root'@'localhost'的方法

    解决步骤: 1.打开终端,输入sudo vi /etc/mysql/debian.cnf 打开/etc/mysql/debian.cnf文件,显示如下: 2.mysql -udebian-sys-ma ...

  8. mysql启动提示 access denied for user root@localhost(using password:YES) 解决办法总结

    首先计入到mysql的客户端命令行. 然后: mysql>grant all privileges on *.* to 'root'@'localhost' identified by '你的密 ...

  9. MySql错误1045 Access denied for user 'root'@'localhost' (using password:YES)

    1.先停止mysql服务 2.进入mysql的安装路径,找到并打开my.ini文件,找到[mysqld],在该行下面添加 skip_grant_tables,也就是通知mysql,在登陆的时候跳过密码 ...

最新文章

  1. 重磅!Gartner公布2019年十大战略科技发展趋势
  2. 【实验】配置802.1x远端认证
  3. 深入::first-letter的研究
  4. dj鲜生-26-登陆时-记住用户名的操作
  5. Java 8 实战学习笔记
  6. 干货!639页《深度学习:Deep Learning》硬核课程PPT
  7. MyEclipse6.5安装SVN插件的三种方法
  8. 比较偏门的JVM语言Quercus - PHP on JVM
  9. python中rect函数_Rect和RectF函数
  10. 组成原理之全加器实验
  11. macd底背离的python_python量化交易是否可以有策略有效识别MACD/SKDJ底背离和顶背离?...
  12. secureCRT免密安装
  13. 鸿蒙初开三界未立,太子长琴
  14. 初探大规模GBDT训练
  15. air for andriod学习笔记1- 将现有fla文件生成为apk
  16. UNIX环境高级编程源码
  17. navicat误删了mysql数据库_navicat for mysql 误删数据库怎么恢复
  18. #WebStorm激活码失效解决方法!
  19. MyEclipse使用Maven创建web项目+搭建SSM框架教程
  20. 2018年小米 Mi air i7-7500u黑苹果efi引导文件

热门文章

  1. 递归实现 1,1,2,3,5,8,….第 30 个数是多少?
  2. php上传文件并存储到mysql数据库的方法
  3. 天猫精灵打开电脑(网络唤醒)
  4. 第四章USB数据流模型
  5. 爬虫小程序 - 单词量测试
  6. 蚁群算法讲解python
  7. 最强神作 Crysis深度剖析与优化指南
  8. java中立方根方法,Java Math.cbrt() 方法
  9. mysql cbrt函数_Hive FUNCTIONS函数
  10. 禁止迅雷极速版强制升级方法