美文网首页
mysql 忘记密码如何修改 mac mysql 版本5.7.1

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

作者: caesarcheng | 来源:发表于2017-04-19 23:29 被阅读0次

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.1

      本文链接:https://www.haomeiwen.com/subject/khsxittx.html