博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ubuntu 16.04 下重置 MySQL 5.7 的密码(忘记密码)
阅读量:4142 次
发布时间:2019-05-25

本文共 919 字,大约阅读时间需要 3 分钟。

编辑mysql的配置文件/etc/mysql/my.cnf,在[mysqld]段下加入一行“skip-grant-tables”。

Ubuntu下忘记MySQL root密码解决方法

重启mysql服务

yxj @yxj:~$ sudo service mysql restart 

用空密码进入mysql管理命令行,切换到mysql库。

yxj @yxj:~$ mysql 

Welcome to the MySQL monitor.  Commands end with ; or \g. 
 
mysql> use mysql 
Database changed 

执行update mysql.user set authentication_string=password('123qwe') where user='root' and Host ='localhost';把密码重置为123456。退出数据库管理。

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host ='localhost';

Query OK, 0 rows affected (0.00 sec)   
Rows matched: 4  Changed: 0  Warnings: 0   

mysql>update user set plugin="mysql_native_password"; mysql>flush privileges;mysql>quit;

回到sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf,把刚才加入的那一行“skip-grant-tables”注释或删除掉。

再次重启mysql服务sudo service mysql restart,使用新的密码登陆,修改成功。

yxj @yxj:~$ mysql -uroot -pnew_pass 

Welcome to the MySQL monitor.  Commands end with ; or \g. 
mysql> 

mysql>mysql -u root -p 再次登录

转载地址:http://zoyti.baihongyu.com/

你可能感兴趣的文章
SP91 未知唤醒源日志
查看>>
Python报错-(2003 Can t connect to MySQL server on 127.0.0.1)
查看>>
Python基础-项目-day5 Web框架
查看>>
Python基础-项目-day6 配置文件
查看>>
SP91 GMS唤醒优化
查看>>
ERROR 1044 (42000)Access denied for user @localhost to database
查看>>
Eclipse安装Pydev后Window-Preferences没有显示PyDev的解决办法
查看>>
Eclipse 安装 Python插件,并运行
查看>>
MySql找不到指定文件,安装的目录
查看>>
Eclipse显示空白符,如空格、制表符、换行符的方法
查看>>
Eclipse配置 Anaconda
查看>>
MarkDown插入图片(使用Github图片床)
查看>>
Window丢失api-ms-win-crt-runtime-l1-1-0.dll
查看>>
Gradle不是内部或外部命令的报错提示
查看>>
Eclipse的Pydev代码格式化对齐
查看>>
Python基础-项目-day 7 mvc
查看>>
Python基础-day8 构建前端,让界面更丰富和好看
查看>>
MySQL的GUI工具
查看>>
Python基础-项目实战-day8新增API
查看>>
Android系统proc下查看cpuinfo的参数信息
查看>>