当前位置:网站首页>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 .
边栏推荐
- Fault analysis | MySQL: unique key constraint failure
- 20220701 barbarat lemma proof
- Démarrage des microservices: passerelle
- 没有Kubernetes怎么玩Dapr?
- 20220701 Barbalat引理证明
- Three paradigms of database design
- Guanghetong's high-performance 4g/5g wireless module solution comprehensively promotes an efficient and low-carbon smart grid
- How to solve the problem of computer jam and slow down
- Relationship and operation of random events
- manjaro安装微信
猜你喜欢
C language - Introduction - Foundation - syntax - data type (4)
How to re enable local connection when the network of laptop is disabled
User login function: simple but difficult
微服務入門:Gateway網關
FOC control
DM8 tablespace backup and recovery
How to choose solid state hard disk and mechanical hard disk in computer
09 softmax regression + loss function
The basic syntax of mermaid in typera
Relationship and operation of random events
随机推荐
Basic operations of databases and tables ----- view data tables
HMS core helps baby bus show high-quality children's digital content to global developers
上周热点回顾(6.27-7.3)
Comparison between sentinel and hystrix
How to play dapr without kubernetes?
Codeforces Round #750 (Div. 2)(A,B,C,D,F1)
Awk from entry to earth (18) GAW K line manual
Codeforces Round #750 (Div. 2)(A,B,C,D,F1)
09 softmax regression + loss function
Getting started with microservices: gateway gateway
DM8 tablespace backup and recovery
How to solve the problem of computer jam and slow down
How to send pictures to the server in the form of file stream through the upload control of antd
Awk from getting started to digging in (9) circular statement
地平线 旭日X3 PI (一)首次开机细节
【无标题】转发最小二乘法
Awk from entry to earth (14) awk output redirection
awk从入门到入土(18)gawk线上手册
LinkedList in the list set is stored in order
Leetcode topic [array] -136- numbers that appear only once