当前位置:网站首页>How to reset the password of MySQL root account
How to reset the password of MySQL root account
2022-07-04 22:22:00 【Wu_ Candy】
Share the theme today :mysql root How to reset the password of the account
I found it two days ago mysql The database suddenly fails to log in , But it was normal to use it last week , After some searching, the cause of the problem is still not found .
DBA Give me an explanation : I suspect that after the host restarts , Some documents (user.*) I lost it , I don't know why . I remember that you also encountered the same problem after restarting .
In this case , Had to reset root Account password . The specific operation steps are as follows
Step1: stop it mysql service
command :systemctl stop mysqld # Stop MySQL
command :systemctl status mysqld # Check the status
Step2: modify /etc/my.cnf To configure , add to skip_grant_tables=1 Startup settings , Pay attention to [mysqld] Add .
Step3: restart mysql And check the status
systemctl start mysqld systemctl status mysqld
Step4: Use mysql Command to connect to mysql The server , To reset root password
use mysql # Get into mysql database select * from user; # Inquire about user surface Check to see if there is root account number , If not, you need to operate as follows insert into sentence :
insert into `user` (`Host`, `User`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `Event_priv`, `Trigger_priv`, `Create_tablespace_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`, `plugin`, `authentication_string`, `password_expired`, `password_last_changed`, `password_lifetime`, `account_locked`) values('%','root','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','','0','0','0','0','mysql_native_password','*753ACFC7D5D71CB67C49345B035ADFAEA169594B','N','2021-03-08 11:00:04',NULL,'N');
If user There is... In the watch root account number , Then you can reset the password directly .
The order is as follows :update user set authentication_string=password('test123') where user='root'
FLUSH PRIVILEGES; # Refresh authorization list
Input again exit sign out mysql
Step5: Will step 2 in /etc/my.cnf Added to the file skip_grant_tables=1 Remove the startup setting , One more systemctl restart mysql Command restart mysql service .
Step6: The problem is solved when logging in again with the reset password .
end
边栏推荐
- Force buckle 2_ 1480. Dynamic sum of one-dimensional array
- 现在mysql cdc2.1版本在解析值为0000-00-00 00:00:00的datetime类
- 短视频系统源码,点击屏幕空白处键盘不自动收起
- 【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
- 电话加密,中间4为****代替
- 抖音实战~评论数量同步更新
- 机器人相关课程考核材料归档实施细则2022版本
- VS2019 C# release下断点调试
- Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
- Introduction and application of bigfilter global transaction anti duplication component
猜你喜欢
机器学习笔记 - 互信息Mutual Information
Scala download and configuration
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
【C语言进阶篇】数组&&指针&&数组笔试题
常用的开源无代码测试工具
More than 30 institutions jointly launched the digital collection industry initiative. How will it move forward in the future?
Common open source codeless testing tools
AscendEX 上线 Walken (WLKN) - 一款卓越领先的“Walk-to-Earn”游戏
Concurrent network modular reading notes transfer
保证接口数据安全的10种方案
随机推荐
How can the advertising system of large factories be upgraded without the presence of large models
PHP short video source code, thumb animation will float when you like it
Representation of confidence interval
面试必备 LeetCode 链表算法题汇总,全程干货!
可视化任务编排&拖拉拽 | Scaleph 基于 Apache SeaTunnel的数据集成
湘江鲲鹏加入昇腾万里伙伴计划,与华为续写合作新篇章
Basic structure of PostgreSQL - table
Use blocconsumer to build responsive components and monitor status at the same time
抖音实战~评论数量同步更新
广电五舟与华为签署合作协议,共同推进昇腾AI产业持续发展
嵌入式开发:技巧和窍门——提高嵌入式软件代码质量的7个技巧
You don't have to run away to delete the library! Detailed MySQL data recovery
Telephone encryption, middle 4 is replaced by * * * *
Spatiotemporal prediction 3-graph transformer
Implementation rules for archiving assessment materials of robot related courses 2022 version
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
Concurrent optimization summary
TLA+ 入门教程(1):形式化方法简介
HDU - 1078 FatMouse and Cheese(记忆化搜索DP)
Huawei Nova 10 series released Huawei application market to build a solid application security firewall