当前位置:网站首页>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
边栏推荐
- php短视频源码,点赞时会有大拇指动画飘起
- 大厂的广告系统升级,怎能少了大模型的身影
- 《命令行上的数据科学第二版》校对活动重新启动
- 阿里推出新品牌“瓴羊”,致力成为“数字化领头羊”
- El tree combined with El table, tree adding and modifying operations
- 卷积神经网络模型之——LeNet网络结构与代码实现
- HUAWEI nova 10系列发布 华为应用市场筑牢应用安全防火墙
- i. Mx6ull driver development | 24 - platform based driver model lights LED
- 电话加密,中间4为****代替
- VIM from dislike to dependence (23) -- the last gossip
猜你喜欢
AscendEX 上线 Walken (WLKN) - 一款卓越领先的“Walk-to-Earn”游戏
i.MX6ULL驱动开发 | 24 - 基于platform平台驱动模型点亮LED
NAACL-22 | 在基于Prompt的文本生成任务上引入迁移学习的设置
close系统调用分析-性能优化
迷失在Mysql的锁世界
Common open source codeless testing tools
传智教育|如何转行互联网高薪岗位之一的软件测试?(附软件测试学习路线图)
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
PMO:比较25种分子优化方法的样本效率
HUAWEI nova 10系列发布 华为应用市场筑牢应用安全防火墙
随机推荐
LOGO特训营 第五节 字体结构与设计常用技法
close系统调用分析-性能优化
TCP协议三次握手过程
WebGIS框架---kalrry
Bizchart+slider to realize grouping histogram
Zhiyang innovation signed a cooperation agreement with Huawei to jointly promote the sustainable development of shengteng AI industry
TLA+ 入门教程(1):形式化方法简介
BigFilter全局交易防重组件的介绍与应用
复数在数论、几何中的用途 - 曹则贤
【C语言进阶篇】数组&&指针&&数组笔试题
QT - plot other problems
如何实现轻松管理1500万员工?
什么是商业智能(BI),就看这篇文章足够了
VIM from dislike to dependence (23) -- the last gossip
凭借了这份 pdf,最终拿到了阿里,字节,百度等八家大厂 offer
With this PDF, we finally got offers from eight major manufacturers, including Alibaba, bytek and Baidu
PostgreSQLSQL高级技巧透视表
Solana链上应用Crema因黑客攻击停运
Challenges faced by virtual human industry
Force buckle 2_ 1480. Dynamic sum of one-dimensional array