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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容