当前位置:网站首页>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
边栏推荐
- With this PDF, we finally got offers from eight major manufacturers, including Alibaba, bytek and Baidu
- Which securities company has the lowest Commission for opening an account online? I want to open an account. Is it safe to open an account online
- 虚拟人产业面临的挑战
- [acwing] solution of the 58th weekly match
- 傳智教育|如何轉行互聯網高薪崗比特之一的軟件測試?(附軟件測試學習路線圖)
- B站大量虚拟主播被集体强制退款:收入蒸发,还倒欠B站;乔布斯被追授美国总统自由勋章;Grafana 9 发布|极客头条
- 服装企业为什么要谈信息化?
- More than 30 institutions jointly launched the digital collection industry initiative. How will it move forward in the future?
- DevEco Device Tool 3.0 Release带来5大能力升级,让智能设备开发更高效
- ACM multimedia 2022 | counterfactual measurement and elimination of social prejudice in visual language pre training model
猜你喜欢
30余家机构联合发起数字藏品行业倡议,未来会如何前进?
How to transfer to software testing, one of the high paying jobs in the Internet? (software testing learning roadmap attached)
湘江鲲鹏加入昇腾万里伙伴计划,与华为续写合作新篇章
赋能数字经济 福昕软件出席金砖国家可持续发展高层论坛
达梦数据凭什么被称为国产数据库“第一股”?
VS2019 C# release下断点调试
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
What is business intelligence (BI), just look at this article is enough
NAACL-22 | 在基于Prompt的文本生成任务上引入迁移学习的设置
可视化任务编排&拖拉拽 | Scaleph 基于 Apache SeaTunnel的数据集成
随机推荐
Implementation rules for archiving assessment materials of robot related courses 2022 version
Common open source codeless testing tools
TCP协议三次握手过程
面试题 01.08. 零矩阵
【C语言进阶篇】数组&&指针&&数组笔试题
Energy momentum: how to achieve carbon neutralization in the power industry?
玩转gRPC—深入概念与原理
面试必备 LeetCode 链表算法题汇总,全程干货!
LOGO特训营 第一节 鉴别Logo与Logo设计思路
HUAWEI nova 10系列发布 华为应用市场筑牢应用安全防火墙
微服务--开篇
HDU - 2859 Phalanx(DP)
A large number of virtual anchors in station B were collectively forced to refund: revenue evaporated, but they still owe station B; Jobs was posthumously awarded the U.S. presidential medal of freedo
PHP short video source code, thumb animation will float when you like it
Short video system source code, click the blank space of the screen, the keyboard does not automatically stow
You don't have to run away to delete the library! Detailed MySQL data recovery
Jvm-Sandbox-Repeater的部署
Ascendex launched Walken (WLKN) - an excellent and leading "walk to earn" game
Redis sentinel simply looks at the trade-offs between distributed high availability and consistency
Is it safe to open an account in the stock of Caicai college? Can you only open an account by digging money?