Mac-mysql initial password forgot to reset MySQL root password

Source: Internet
Author: User

Under what circumstances do I need to reset the root password? That's what we forgot. There is a kind of comparison pit, that is the author of this situation. Under normal circumstances, after the MySQL installation, will pop up a dialog box, showing a temporary root password, but no matter how I reinstall MySQL, never give me a temporary root password, resulting in the author has been unable to log on MySQL, no way, can only use hard, that is to reset the password.

To stop the MySQL service, turn on system Preferences, find MySQL and click on Stop MySQL server.

Step1: Apple ---System Preferences,/usr/local/mysql/bin/enter the following command to disable the MySQL authentication feature after entering the login administrator right after sudo su returns. /mysqld_safe--skip-grant-tables & MySQL will restart automatically after return (the MySQL status in preferences will change to running)

Open two terminals, enter in the first terminal sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables , enter the current user's password:

1045 (28000for'root'@'localhost' (using password:no)

So let's change to the following:

macdemacbook-pro:~ mac$ mysql-uroot-h127. 0.0. 1 -1045 (28000for'root'  localhost' (using password:yes)

Then after entering the second terminal sudo /usr/local/mysql/bin/mysql -u root , and then entering the current user's password, the following interface appears

macdemacbook-pro:~ mac$ Sudo/usr/local/mysql/bin/mysql-u rootpassword:welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 3Server Version:5.7. AHomebrewcopyright (c) -,2018, Oracle and/or its affiliates. All rights reserved. Oracle isA registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h'  forHelp. Type'\c'To clear the current input statement.mysql>

then enter the command UPDATE mysql.user SET authentication_string=PASSWORD(‘新密码‘) WHERE User=‘root‘;Enter, the following interface appears, indicating the success of the modification.
mysql> UPDATE mysql.user SET authentication_string=password ('123456') WHERE user='  root'  1 1 Warning (0.00 1  1  1

Next enter the flush privileges, and the following interface appears in the carriage return
mysql>0 rows affected (0.01 sec)

Finally, enter \q and exit. Turn off the first terminal, go back to your system preferences, and turn on MySQL again.
mysql> \qbye

macdemacbook-pro:~ mac$ mysql-uroot-h127.0.0.1-penter Password:error1045(28000): Access denied forUser'Root'@'localhost'(usingpassword:yes) Macdemacbook-pro:~ mac$ Sudo/usr/local/mysql/bin/mysql-u rootpassword:welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 3Server Version:5.7. AHomebrewcopyright (c) -,2018, Oracle and/or its affiliates. All rights reserved. Oracle isA registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h'  forHelp. Type'\c'To clear the current input statement.mysql> UPDATE mysql.user SET authentication_string=password ('123456') WHERE user='Root'; Query OK,1Row affected,1Warning (0.00sec) Rows matched:1Changed:1Warnings:1MySQL>FLUSH privileges; Query OK,0Rows Affected (0.01sec) MySQL>\qbyemacdemacbook-pro:~ mac$

Mac-mysql initial password forgot to reset MySQL root password

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.