MySQL5.7.26 忘记Root密码小计
以前直接修改mysql.user就ok了,现在不行了,正好虚拟机MySQL的root密码忘记了,就简单记录下:(本方法不适合互联网线上项目,除非你不在意这段时间的损失)
PS:以UbuntuServer为例(CentOS你把配置文件的位置换下就ok了)
坑点:
- 不能和以前一样直接修改user表了,需要使用新命令
alter user 'root'@'localhost' identified with mysql_native_password by '复合密码强度的新密码';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statementflush privileges;
修改密码

附录
dnt@ubuntuserver:~$ vi /etc/mysql/mysql.conf.d/mysqld.cnf
dnt@ubuntuserver:~$ cat /etc/mysql/mysql.conf.d/mysqld.cnf |grep skip
skip-external-locking
# Instead of skip-networking the default is now to listen only on
skip_name_resolve=on
skip-grant-tables
dnt@ubuntuserver:~$ sudo systemctl restart mysql
dnt@ubuntuserver:~$ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user();
+--------+
| user() |
+--------+
| root@ |
+--------+
1 row in set (0.01 sec)
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'WWW.baidu.com1';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'WWW.baidu.com1';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
恢复正常

附录
dnt@ubuntuserver:~$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
dnt@ubuntuserver:~$ cat /etc/mysql/mysql.conf.d/mysqld.cnf |grep skip
skip-external-locking
# Instead of skip-networking the default is now to listen only on
skip_name_resolve=on
# skip-grant-tables
dnt@ubuntuserver:~$ sudo systemctl restart mysql
dnt@ubuntuserver:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
MySQL5.7.26 忘记Root密码小计的更多相关文章
- mysql 5.7.26 忘记root密码
1.关闭mysql [root@mysql ~]# /etc/init.d/mysqld stopShutting down MySQL.. SUCCESS! 2.修改参数文件/etc/my.cnf ...
- MySQL5.7 忘记root密码,怎么破?
MySQL5.7 忘记root密码,怎么破? 关服 # kill $mysql_pid 免密启动 # /usr/local/mysql57/bin/mysqld_safe --defaults-fil ...
- Linux忘记root密码怎么办?
开篇前言:Linux系统的root账号是非常重要的一个账号,也是权限最大的一个账号,但是有时候忘了root密码怎么办?总不能重装系统吧,这个是下下策,其实Linux系统中,如果忘记了root账号密码, ...
- Mac上MySQL忘记root密码且没有权限的处理办法&workbench的一些tips (转)
忘记Root密码肿么办 Mac上安装MySQL就不多说了,去mysql的官网上下载最新的mysql包以及workbench,先安装哪个影响都不大.如果你是第一次安装,在mysql安装完成之后,会弹出来 ...
- mysql 免安装与 忘记root密码 密码过期
免安装: 参考 :https://blog.csdn.net/werwqerwerwer/article/details/52919939 注:别忘了配置环境变量 忘记root密码解决办法: 1. ...
- 忘记root密码怎么办-单用户模式修改root密码
忘记root密码怎么办-单用户模式修改root密码================================= 1,开机3秒内按下向下的方向键,目的是为了不让它进入系统,而是停留在开机界面. 2 ...
- CentOS6.5的安装及忘记root密码的措施
CentOS6.5的安装及忘记root密码的措施 VMware虚拟机的配置 1.文件->新建->自定义->下一步 2.选择稍后安装操作系统 我们将采用自定义安装,杜绝VMware的一 ...
- mysql-管理命令【创建用户、授权、修改密码、删除用户和授权、忘记root密码】
一.创建用户 命令: CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 关键参数说明: username - 创建登录用户名, host ...
- mysql忘记root密码连接本地库
http://www.cnblogs.com/zf2011/archive/2012/03/13/2393387.html 今天想做个小项目,决定用mysql数据库,但是好久没用mysql了,也忘掉了 ...
随机推荐
- Mysql5.6压缩包安装到windows&& 卸载命令
1.根目录下有一个my-default.ini,复制一下,重命名为my.ini,然后改一下my.ini为符合你情况的配置,一般只需要改basedir .datadir .port ,注意前边的井号去掉 ...
- android 多应用程序数据共享 ContentProvider和ContentResolver
android 没有一个可以将所有应用程序数据统一放置的地方,即两个应用程序间的数据不能共享.但ContentProvider与ContentResolver可以解决多应用程序数据共享. 我们都知 ...
- Docker URL REST API访问设置
Docker daemon 绑定到该端口上. 默认情况下,docker daemon使用unix socket(unix:///var/run/docker.sock) 1.先停止docker dae ...
- PHP面试题及答案解析(3)—MySQL数据库
1.mysql_num_rows()和mysql_affected_rows()的区别. mysql_num_rows()和mysql_affected_rows(),这两个函数都作用于 mysql_ ...
- 微软同步发行Windows 10和Windows 10 Mobile系统更新
微软今天同步公布了新的 Windows 10 Redstone PC 和 Windows 10 Mobile 预览版. PC 版本是 Build 14271.Mobile 版本是 Build 1426 ...
- SpringMVC 学习笔记(十一) SpirngMVC执行流程
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYTY3NDc0NTA2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...
- <!DOCTYPE>奇葩的问题
作用:<!DOCTYPE> 声明不是 HTML 标签:它是指示 web 浏览器关于页面使用哪个 HTML 版本号进行编写的指令. 1.:<!DOCTYPE> 声明没有结束标签. ...
- 解读Unity中的CG编写Shader系列3——表面剔除与剪裁模式
在上一个样例中,我们得到了由mesh组件传递的信息经过数学转换至合适的颜色区间以颜色的形式着色到物体上. 这篇文章将要在此基础上研究片段的擦除(discarding fragments)和前面剪裁.后 ...
- rmdir 命令
rmdir 不能删除非空目录 1.rmdir aa 删除空文件夹aa 2.rmdir -p aa 递归删除文件夹aa 当aa子文件夹被删除后aa也变成空文件夹的话aa也被删除
- C#多线程简单例子讲解
C#多线程简单例子讲解 标签: 多线程c#threadobjectcallbacktimer 分类: C#(7) 转载网址:http://www.knowsky.com/540518.html .NE ...