What should I do if I forget my initial password for MySQL on MAC?

Source: Internet
Author: User
Tags mysql commands

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.