解决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,自然对这个开源项目毫无 ...
随机推荐
- JavaScript实现网页回到顶部效果
在浏览网页时,当我们浏览到网页底部,想要立刻回到网页顶部时,这时候一般网页会提供一个回到顶部的按钮来提升用户体验,以下代码实现了该功能 HTML代码: <p id="back-top& ...
- JavaScript之鼠标事件
事件三要素: 事件源.事件类型(点击onclick)=function(){ 事件触发后执行的代码 } 案例: function abb(a){ return document.getElementB ...
- jquery实现弹出层完美居中效果
代码如下: showDiv($("#pop"));function showDiv(obj){ $(obj).show(); center(obj); $(window).scro ...
- 基于webpack的前端工程化开发解决方案探索(三):webpack-dev-server
前两篇中我们使用webpack完成了静态资源(css/js/img)等自动写入HTML模板中,同时还可以为静态资源添加hash版本号,既满足了我们对于静态资源的打包要求,同时又无需开发人员介入打包过程 ...
- 编译 Unity 4.3.1 引擎源码
引言 Unity 官方从 Unity 2017.1 版本开始,开源了引擎和编辑器的C#源码(源码地址:UnityCsReference),但核心的 C/C++ 部分源码并未开源. 编译环境 网上主要的 ...
- Jmeter计数器的使用-转载
说一下jmeter中,配置元件-计数器的使用. 如果需要引用的数据量较大,且要求不能重复或者需要自增,那么可以使用计数器来实现. 1.启动jmeter,添加线程组,右键添加配置元件——计数器,如下图: ...
- echarts Y轴名称显示不全(转载)
转载来源:https://blog.csdn.net/qq8241994/article/details/90720657今天在项目的开发中遇到的一个问题,echarts Y轴左侧的文字太多了,显示不 ...
- Mysql 整数类型的字段的属性设置及常用的函数
数据类型 二.MySQL支持的数据类型 数值类型.日期类型.字符串类型 1.数值类型 1)整数类型 tinyint.smallint.mediumint.int和bigint 2)zerofill属性 ...
- matplotlib绘图难题解决
# coding=utf-8 import pandas as pd import yagmail import requests import arrow import numpy as np im ...
- MyBatis日记(五):一对一关系,一对多关系
一对一关系: 首先在数据库中新增地址表(t_address)用于存储人员的地址信息: CREATE TABLE `t_address` ( `id` ) NOT NULL AUTO_INCREMENT ...