解决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,自然对这个开源项目毫无 ...
随机推荐
- Python基础知识(八)----文件操作
文件操作 一丶文件操作初识 ###f=open('文件名','模式',编码): #open() # 调用操作系统打开文件 #mode #对文件的操作方式 #encoding # 文件的编码格式 存储编 ...
- ORACLE SQL 笔记
根据数据权限查询 SELECT * FROM ( SELECT ROWNUM AS ROWNO, AA.* FROM ( SELECT DISTINCT A.OBJECTID InstanceID , ...
- [LeetCode] 198. 打家劫舍 ☆(动态规划)
描述 你是一个专业的小偷,计划偷窃沿街的房屋.每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警. 给定一个 ...
- mariadb远程授权问题
安装mariadb后,使用远程连接时 密码没有问题 但是每次打开都报这个错误: 这个错误是在进行远程连接的时候密码正确, 但是,进行远程授权的时候授权密码错误. 在数据库中执行下述代码即可: GRAN ...
- [转载]Mysql数据库千万级数据处理优化
转载:http://blog.sina.com.cn/s/blog_6dcd17320100tm6o.html 1. 对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by ...
- 【Beta】Scrum meeting3
第三天:2019/6/26 前言: 第3次会议于6月26日在教9-501召开. 对每个人负责撰写的文档进行分配,并讨论其中模糊的问题,时长30min. 本日任务完成情况 成员 今日完成任务情况 成员贡 ...
- 做阉割版Salesforce难成伟大的TOB企业
https://www.lieyunwang.com/archives/446227 猎云注:当前中国市场环境下,有没有可能诞生一批SaaS级企业服务公司?东方富海合伙人陈利伟用三个方面基础性问题解答 ...
- GSM/GPRS模块 AT指令集C语言编程——基于有方M660+和MSP430单片机
GSM/GPRS芯片是手机中负责收发短信.拨打电话以及访问GPRS网络的核心器件.有方M660+为深圳有方公司生产的一款超小封装的GSM/GPRS工业无线模块,可以提供高品质的语音.短信.数据业务等功 ...
- hdu6172&&hdu6185&&P5487——BM算法
hdu6172 模板的简单应用 先根据题中的表达式求出前几项,再上BM,注意一下n的大小关系. #include <bits/stdc++.h> using namespace std; ...
- freemarker使用shiro标签(spring boot)
freemarker使用shiro标签(spring boot) 2018年07月03日 14:20:37 niu_sayok 阅读数:348更多 个人分类: freeMarkerShiro 首先 ...