当前位置:网站首页>Mac platform forgets the root password of MySQL
Mac platform forgets the root password of MySQL
2022-07-04 08:52:00 【sanqima】
MySQL The database has not been used for a long time , Use... In recent days MySQL, Find out root I forgot the password . But also good , have access to MySQL Security mode to modify root password . The specific method is as follows :
1 stop it MySQL service
Method 1 : Close with command
In the black frame , Enter the following command , To close MySQL service , Pictured (1) Shown .
sudo /usr/local/mysql/support-files/mysql.server stop
Method 2 : stay [ System preferences ] Inside closed
If you click [Stop MySQL Server] The button doesn't respond , Then enter the following command in the command line , avoid MySQL Restart again and again :
sudo launchctl unload -w /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo pkill mysqld
2 Enter safe mode
## Get into MySQl Installation directory
cd /usr/local/mysql/bin
## Turn on safe mode
sudo ./mysqld_safe --skip-grant-tables --skip-networking
3 modify root password
3.1 update command
Reopen a black box console , Enter the following command :
## With root Enter the database as , If there is a password prompt , Then go straight back
./mysql -u root
## Use the name mysql The database of
use mysql;
## Update the password
update user set authentication_string=password(' Your password ') where user='root';
## Save password
flush privileges;
## sign out
exit
3.2 alter command
Press Ctrl+Z Close the black window in safe mode , Re enter mySQL database , Use alter command , Change the password for the second time ( The password here is the same as the first time ), as follows :
cd /usr/local/mysql/bin
./mysql -u root -p
Enter the new password just set
alter user 'root'@'localhost' identified by ' Your password ';
flush privileges;
exit
- situation 1) Forgotten password :
Enter safe mode , Password to be set 2 Time , For the first time update command , The second, alter command . - situation 2) Update the password :
If you know the old password , You don't need to enter safe mode , Just use alter Just modify the command .
This method , in the light of MySQL v5.7.31 ~ v8 edition .
边栏推荐
- Getting started with microservices: gateway gateway
- awk从入门到入土(8)数组
- 埃氏筛+欧拉筛+区间筛
- awk从入门到入土(18)gawk线上手册
- From scratch, use Jenkins to build and publish pipeline pipeline project
- FRP intranet penetration, reverse proxy
- 2022 electrician (intermediate) examination question bank and electrician (intermediate) examination questions and analysis
- Call Baidu map to display the current position
- System disk expansion in virtual machine
- [untitled] 2022 polymerization process analysis and polymerization process simulation examination
猜你喜欢
埃氏筛+欧拉筛+区间筛
How to play dapr without kubernetes?
ctfshow web255 web 256 web257
What if I forget the router password
[error record] no matching function for call to 'cacheflush' cacheflush();)
没有Kubernetes怎么玩Dapr?
MySQL relearn 1-centos install mysql5.7
ArcGIS应用(二十二)Arcmap加载激光雷达las格式数据
How to solve the problem of computer jam and slow down
Four essential material websites for we media people to help you easily create popular models
随机推荐
How to play dapr without kubernetes?
Basic discipline formula and unit conversion
如何通过antd的upload控件,将图片以文件流的形式发送给服务器
How to play dapr without kubernetes?
老掉牙的 synchronized 锁优化,一次给你讲清楚!
ES6 summary
Talk about single case mode
根据数字显示中文汉字
Call Baidu map to display the current position
NewH3C——ACL
2022 tower crane driver examination and tower crane driver examination questions and analysis
Awk from digging into the ground to getting started (10) awk built-in functions
C語言-入門-基礎-語法-[運算符,類型轉換](六)
Openfeign service interface call
ctfshow web255 web 256 web257
A subclass must use the super keyword to call the methods of its parent class
What if I forget the router password
awk从入门到入土(8)数组
awk从入门到入土(14)awk输出重定向
The map set type is stored in the form of key value pairs, and the iterative traversal is faster than the list set