What should I do if I forget my initial password for MySQL on MAC?
For your reference, the solution for forgetting the initial password of MySQL on MAC is as follows:
Install MySQL dmg on the official website.
1. Set mysql commands
Input from Terminal
mysql --version
If the version number is displayed, it indicates that it is normal. If the command not found is displayed, follow the following code link to install the path:
cd /usr/local/bin/sudo ln -fs /usr/local/mysql/bin/mysql mysql
2. Disable the mysql service.
sudo /usr/local/mysql/support-files/mysql.server stop
3. Start mysql in Safe Mode
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
Then enable the system preference settings and select mysql. The mysql service will be found and restarted.
4. Return to the terminal
Command + N re-open a terminal and enter
Mysql -u root
In this case, you can directly access mysql without a password and modify any password.
5. Change the password on the new terminal
Mysql> flush privileges; mysql> set password for root @ 'localhost' = PASSWORD ('000000'); // You can also modify other passwords. // Finally, refresh mysql> flush privileges;
Then you can log on to mysql with a new password.
For more information about MySQL password operations, refer to the topic: MySQL password operations summary for learning.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.