First KindMySQL version: 5.7.171. First we want to shut down the MySQL service sudo/usr/local/mysql/support-files/mysql.server Stop2. We're going to start with Safe mode mysqlsudo/usr/ Local/mysql/bin/mysqld_safe--skip-grant-tables3. Log in to the MySQL service using the root account/usr/local/mysql/bin/mysql u Root4. Modify the root account password (this is actually the SQL statement) Update mysql.user set Authentication_string=password (' Qingyun1 ') where user= ' root ' and Host = ' localhost '; if necessary, it is recommended to run: Flush privileges;5. Shutdown Safe Mode, normal restart mysqlsudo/usr/local/mysql/support-files/ Mysql.server restart6. Normal use of root account and password connection Mysql/usr/local/mysql/bin/mysql-u root-p the second kind
If you forget the password, forcibly modified: 1:? Stop MySQL service sudo/usr/local/mysql/support-files/mysql.server stop2:? Enter terminal input: cd/usr/local/mysql/bin/? After carriage return; login administrator permissions sudo su? Enter the following command to disable the MySQL authentication feature./mysqld_safe--skip-grant-tables &? MySQL will restart automatically after carriage return (the MySQL status in the preferences will become running) 3. ? Enter the command./mysql. Enter command FLUSH privileges after carriage return; After entering, enter the command ALTER USER ' root ' @ ' localhost ' identified by ' your new password ';
1. Stop MySQL server. Usually is in ' System Preferences ' > MySQL > ' Stop mysql Server ' or: Sudo/usr/local/mysql/support-files/mysql.server stop2. Open Terminal, enter: Sudo/usr/local/mysql/bin/mysqld_safe--skip-grant-tables3. Open another new terminal, enter: Sudo/usr/local/mysql/bin/mysql-u root UPDATE mysql.user SET authentication_string=password (' New password ') WH ERE user= ' root '; FLUSH privileges; \q4. Restart Sudo/usr/local/mysql/support-files/mysql.server restart* above methods for
MySQLV5.7.9, old version of MySQL please use: UPDATE mysql.user SET password=password (' New password ') WHERE user= ' root ';
these three ways can be used according to the situation!
Change the password for MySQL under Mac