MySQL:忘记root密码:修订间差异
imported>Soleverlee 以“首先停止mysql <source lang="bash"> service mysql stop </source> 然后以安全模式启动mysql在后台运行: <source lang="bash"> mysqld_safe --skip-grant-...”为内容创建页面 |
imported>Soleverlee 无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第14行: | 第14行: | ||
修改MySQL的root密码: | 修改MySQL的root密码: | ||
<source lang="sql"> | <source lang="sql"> | ||
update user set password=PASSWORD(' | update user set password=PASSWORD('123456') where User='root'; | ||
#MySQL 5.7 | |||
update user set authentication_string=password('123456') where user='root'; | |||
flush privileges; | flush privileges; | ||
</source> | </source> | ||
如果提示错误的话: | |||
<pre> | |||
You must reset your password using ALTER USER statement before executing this statement. | |||
</pre> | |||
需要修改密码: | |||
<source lang="bash"> | |||
mysql -uroot -p | |||
> set password=password('123456...') | |||
</source> | |||
[[Category:Database]] | [[Category:Database]] |
2017年5月11日 (四) 09:17的最新版本
首先停止mysql
service mysql stop
然后以安全模式启动mysql在后台运行:
mysqld_safe --skip-grant-tables &
然后就可以以root登录到mysql服务器上
mysql -u root
use mysql
修改MySQL的root密码:
update user set password=PASSWORD('123456') where User='root';
#MySQL 5.7
update user set authentication_string=password('123456') where user='root';
flush privileges;
如果提示错误的话:
You must reset your password using ALTER USER statement before executing this statement.
需要修改密码:
mysql -uroot -p
> set password=password('123456...')