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