MySQL change root user password for Mac

Source: Internet
Author: User
Tags safe mode mysql command line

Environment

MySQL version: 5.7.12
Operating system: OSX 10.11
installation files:. dmg files

MYSQL:MYSQL-5.7.12-OSX10.11-X86_64.DMG (note 5.7 is a bit different from the previous field, which is said below)

Step 1

Turn off the MySQL service. Whether you have the MySQL service turned on or not, run the following command for insurance purposes.

sudo /usr/local/mysql/support-files/mysql.server stop

(Note: I have an error here: error! MySQL server PID file could not being found! I go directly to the system Preferences--other (at the bottom) into the mysql--> Close is enough, the second step is the same)

Step 2

Safe mode to start MySQL.

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

(The second step seems to be still not works, as follows:

1. In the terminal, enter the command to add the MySQL path:

Path= "$PATH":/usr/local/mysql/bin Note: As long as the discovery of this error Mysql:command not found use PATH this line of code, and then enter your previous error command line can be

2. Get Administrator Privileges

sudo su (enter your notebook's password)

3. Cross the permission table and log in to MySQL directly

Mysqld_safe--skip-grant-tables--skip-networking &

)

In Safe mode, you can open the MySQL command line window directly without requiring a password.

Step 3

Create a new terminal, change the root password,

Note here that 5.7 compared to previous versions, the password field in the Mysql.user table was changed to: authentication_string

Enter the following command one by one, modify the root password and exit. If you continue to use password, you will get an error and cannot find this field

mysql -u rootUPDATE mysql.user SET authentication_string=PASSWORD(‘my-new-password‘) WHERE User=‘root‘;FLUSH PRIVILEGES;\q

will be my-new-password replaced with your new password. After running the above command, the root password is changed to the password you set.

Test

Run the following command to test if the password was modified successfully.

-u root -p

Then enter the password for your new settings.

If the input is correct, the MySQL command line window should appear, as follows:

Tips
    1. After installing MySQL through the. dmg file, the MySQL icon appears in the system settings and provides a GUI service to open and close the MySQL service.

    2. command line to open and close the MySQL service
sudo /usr/local/mysql/support-files/mysql.server startsudo /usr/local/mysql/support-files/mysql.server stop
    • 1
    • 2
Reference

Reset MySQL root Password in OSX

How Mac starts MySQL:

Http://jingyan.baidu.com/article/48a42057e2b2b9a9242504a2.html

MySQL cannot log on to the root user solution

http://www.euryugasaki.com/archives/853

MySQL change root user password for Mac

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.