Initialize the mysql root Password in MAC

Source: Internet
Author: User

Initialize the mysql root Password in MAC

1. Turn off the mysql service, open the mysql at the end of the system settings, and then turn mysql off first.

 

2. Generate a file named mysql-init, put in the file: a sentence, this sentence is different in different versions, as shown below: (not included in the brackets)

 

Alter user 'root' @ 'localhost' identified by 'new password'; (MySQL 5.7.6 and later)

 

Set password for 'root' @ 'localhost' = password ('new password'); (MySQL 5.7.5 and earlier)

 

3. cd/usr/local/mysql/bin/

Sudo su

Mysql_safe-init-file =/home/me/mysql-init &

Mysql_safe-skip-grant-tables &

./Mysql

Flush privileges;

Update mysql. user set authentication_string = password ('new password you defined in the file'), password_expired = 'n' where user = 'root' and host = 'localhost ';

Flush privileges;

Quit;

./Mysql-u root-p

Just enter your new password.

Reference: http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

B .5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems Section

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.