首页 > 代码库 > mac mysql5.7重置root密码

mac mysql5.7重置root密码

先停止mysql服务

//停止表权限
 cd /usr/local/mysql/bin/
./mysqld_safe --skip-grant-tables &

 

直接mysql 进入数据库

update mysql.user set authentication_string=password(newpassword) where user=root and Host = localhost;
flush privileges

 

使用新密码进入数据库后任何操作都会提示:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
//你必须重置您的密码使用ALTER USER语句之前执行这

执行:

SET PASSWORD = PASSWORD(newpassword);

即可!

mac mysql5.7重置root密码