Home > Database > Mysql Tutorial > body text

How to reset the MySQL password after forgetting it under Mac operating system_MySQL

PHP中文网
Release: 2016-08-20 08:48:08
Original
1412 people have browsed it

After installing MySQL, the system gives a default password and then says if you forget the default password. . . . . . I copied the default password and took just one step. This step was the beginning of my long journey. The password he gave me was too complicated, so of course I had to change it, and I had to pretend I didn’t remember the password, so I was on the road to no return. . . . . .

This process is sad. There is so much information on the Internet. The key is that everyone has their own wrong methods. After trying for a long time, there is no right one. When I am about to break the psychological defense and go through the MySQL documentation, I have successfully changed it. . No article gave me the complete answer. I consulted several guides and built the car behind closed doors. Give yourself a thumbs up. Without further ado, just follow me step by step.

Close the mysql server

sudo /usr/local/mysql/support-files/mysql.server stop
Copy after login

You can also turn it off in MySQL in the system preferences.

cd /usr/local/mysql/bin 进入目录
sudo su 获取权限
./mysqld_safe --skip-grant-tables & 重启服务器
重开个终端,
Copy after login

Configuration short command:

alias mysql=/usr/local/mysql/bin/mysql

Enter mysql to enter the mysql command mode
use mysql to enter the mysql database
flush privileges; probably to obtain permissions, Otherwise he won't let you change it.
set password for 'root'@'localhost'=password('new password'); Completed the modification

Oh my God, I finally changed it.

If you know the password:

mysqladmin -u root -p password New password. . . . . . . . . . .

The above is the method that the editor introduces to you on how to reset the MySQL password after forgetting it on Mac. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support of the website!

PS: Quick solution for forgotten MYSQL database password under Mac operating system

1. In the system preferences, stop the MYSQL service.;

2. cd /usr/local/mysql-... ../bin

sudo ./mysqld_safe--skip-grant-tables

3. Log in to MySQL;

mysql

4. Leave the root user’s password blank;

mysql> update mysql.user set password=‘' whereUser='root'; 
mysql> flush privileges; 
mysql> quit
Copy after login

5. Restart MySQL service,

6. Add password mysql> mysqladmin -u root -p password 123 Change the password to 123

The above is how to reset the MySQL password after forgetting it under the Mac operating system_MySQL content, more related content Please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!