1. Download mysql for mac on the official website, two formats dmg (direct installation) and tar (decompression free installation)
If it is dmg, it is automatically installed in the / usr / local / mysql directory;
If it is tar, drag the file into the / usr / local / directory after decompression:
a: Unzip, enter command in terminal
cd / Users / Downloads Enter
tar zxvf <your mysql package name> .tar.gz
b: move, enter command
sudo mv <your mysql unzipped file name> usr / local / mysql
2. At this time, mysql is already in the / usr / local / mysql directory
Enter the command in the terminal
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
This operation is for more convenient access to the path, so the path is aliased
3. Next reset the password
Enter the command in the terminal
mysqladmin -u root -p password newpassword ( newpassword here is the new password you want to set)
At this time, the terminal will prompt you to enter the original password. Before the mysql5.6 version, the system will default to the original password as root.
If you really forget it, please open the notification and find the notification sent to you by MySQL Installer. The message is the password at the end;
After entering the old password, the new password is successfully changed
4. Log in to mysql with the new password
input in terminal
mysql -u root -p Enter
Enter the new password and press Enter
login successful!