解决MySql ERROR 1698 (28000) 错误:Access denied for user 'root'@'localhost'
今天尝试在Ubuntu虚拟机上安装MySql 数据库(版本是:5.7.23-0Ubuntu0.18.04.1),数据库安装很简单,就是三行命令:
- sudo apt-get install mysql-server # 下载安装mysql的服务端
- sudo apt-get install mysql-client # 下载安装mysql的客户端
- sudo apt-get install libmysqlclient-dev
但是,看似很顺利简单的安装过程,在第一次登陆的时候却遇到了麻烦。
- ~$ mysql -u root -p
- Enter password:
- ERROR 1698 (28000): Access denied for user 'root'@'localhost'
然后,在网上找了很多的教程,最后实验成功的是这个方案:
解决步骤:
(1) 停止mysql服务:
~$ sudo service mysql stop
(2)以安全模式启动MySQL:
~$ sudo mysqld_safe --skip-grant-tables &
(3)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)
(4)查看一下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)
(5)关于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)
(6)重启服务,问题就解决了:
- ~$ 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)
解决MySql ERROR 1698 (28000) 错误:Access denied for user 'root'@'localhost'的更多相关文章
- (转载)解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password yes
今天想用用MySQL 数据库 谁知道老提示 1045 access denied for user 'root'@'localhost' using password yes 最后在csdn 上找到 ...
- 解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password yes
今天想用用MySQL 数据库 谁知道老提示 1045 access denied for user 'root'@'localhost' using password yes 最后在csdn 上找到 ...
- 数据库之MySQL ERROR 1698 (28000) 错误:Access denied for user 'root'@'localhost'" error【摘抄】
声明:全文均摘抄于MySQL ERROR 1698 (28000) 错误 //错误起源: ~$ mysql -u root -p Enter password: ERROR 1698 (28000): ...
- 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 ...
- MySQL ERROR 1698 (28000) 错误
之前MySQL服务端本机上使用密码登陆root账号是没有问题的,但是今天不知道是因为动了哪里,登陆失败并有这个错误代码: ~$ mysql -u root -p Enter password: ERR ...
- mysql 创建帐号出现 Access denied for user 'root'@'localhost'错误(转载)
从供应商那边接手一个MySQL数据库(数据库版本为5.7.21 MySQL Community Server (GPL)),在创建账号时遇到了“ERROR 1044 (42000): Access d ...
- eclipse不正常编译导致错误:Access denied for user 'root'@'localhost' (using password: YES)
使用eclipse连接mysql报错:Access denied for user 'root'@'localhost' (using password: YES) 连接代码没有任何问题,网上找了很多 ...
- phpMyAdmin出现错误 Access denied for user 'root'@'localhost' (using password: NO)
今天安装wmpp,之后启动后点击phpMyAdmin 报拒绝连接错误:#1045 - Access denied for user 'root'@'localhost' (using password ...
- 解决:MySQL 报错:1045 - Access denied for user 'root'@'localhost'(using password YES)
一.前言 今年疯狂迷上了开源,只要看到好的开源项目,就会不顾一切一股脑扎进去研究,五一期间发现一个很好的关于众筹的开源项目,但不巧,这个项目竟然是 PHP 写的,没学过 PHP,自然对这个开源项目毫无 ...
随机推荐
- Flutter — IDE Shortcuts for Faster Development
https://medium.com/flutter-community/flutter-ide-shortcuts-for-faster-development-2ef45c51085b If yo ...
- js节流与防抖函数封装
js节流与防抖函数封装 常见应用场景: window的 resize 和 scroll 事件: 文字输入时的 keyup 事件: 元素拖拽.移动时的 mousemove 事件: 防抖 定义:多次触发事 ...
- oracle 数据库导入导出语句
oracle的exp/imp命令用于实现对数据库的导出/导入操作;exp命令用于把数据从远程数据库服务器导到本地,生成.dmp文件;imp命令用于把本地的数据库.dmp文件从本地导入到远程的oracl ...
- echarts Y轴名称显示不全(转载)
转载来源:https://blog.csdn.net/qq8241994/article/details/90720657今天在项目的开发中遇到的一个问题,echarts Y轴左侧的文字太多了,显示不 ...
- SQL SERVER升级2017
SQL SERVER升级2017 摘要 本文只介绍了SQL SERVER升级到2017(在简单环境下),分为开始升级前的检查事项,升级操作步骤,升级后对新实例的配置. 检查事项 1.检查当前版本是否可 ...
- 05-jQuery介绍
本篇主要介绍jQuery的加载.jquery选择器.jquery的样式操作.jQuery的事件.jquery动画等相关知识. 一.jQuery介绍 jQuery是目前使用最广泛的javascript函 ...
- 阿里云云计算助理工程师认证(ACA)
经过两天的学习(观看视频,阅读官方帮助文档),完成了初级云计算认证. 本次考试难度相对较低,考察内容较为初级 考点主要考察学员是否真正的动手实验过,不局限于视频中讲解的内容,较多的考点为视频中操作演示 ...
- Linux CentOs下安装lnmp
1.下载源码包 以root目录为例: cd ~ # 下载安装包 wget http://nginx.org/download/nginx-1.17.2.tar.gz # nginx wget http ...
- webapi之owin的oauth2.0密码模式_01概述
一般在webapi接口中,为了防止接口被随意调用,都会验证用户身份. 然而不能每次调用接口都需要用户输入用户名密码来验证,这时就需要授权颁发令牌了,持有令牌就可以访问接口,接口也能验证令牌身份. 简单 ...
- 关于 ES5 & ES6 数组遍历的方法
ES5 数组遍历方法 1.for 循环 , , , , ] ; i < arr.length; i++) { console.log(arr[i]) } 2.forEach , , , , ] ...