mysql 忘记密码如何修改 mac mysql 版本5.7.18

Step 1 : stop mysql server if it`s running 

ps -ef | grep mysql          ##----this command check mysql / mysqld is one of the running processes.

sudo pkill mysqld           ##-----this command will stop the running mysql processes.

Step 2 : run mysqld_safe with kipping grant tables 

sudo mysqld_safe --skip-grant-tables --skip-networking &

step 3 : login mysql as root without password in another terminal 

sudo  mysql -u  root 

step 4 : change the password in mysql shell 

FLUSH PRIVILEGES;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';        ##-----For MySQL  5.7.6 and newer ; for the older version = UPDATEuserSETpassword=PASSWORD("ualue=42")WHEREuser="root";

FLUSH PRIVILEGES;

step 5 : quit mysql shell 

quit  or \q    ##--- will quit mysql shell 

step 6 : stop mysql_safe mode and restart mysql

sudo pkill mysql

你可能感兴趣的:(mysql 忘记密码如何修改 mac mysql 版本5.7.18)