Linux下的MySQL进入安全模式,修改密码
2019-06-12 本文已影响0人
风雪山神喵
有些时候,会忘记数据库的用户密码,只需要进入安全模式,进行修改就可以了
1、停止正在运行的MySQL进程
【Linux】运行 killall -TERM mysqld
2、以安全模式启动MySQL
【Linux】运行 /usr/local/mysql/bin/mysqld_safe –skip-grant-tables &
【Windows】在命令行下运行 X:/MySQL/bin/mysqld-nt.exe –skip-grant-tables
3、完成以后就可以不用密码进入MySQL了
【Linux】运行 /usr/local/mysql/bin/mysql -u root -p 进入
【Windows】运行 X:/MySQL/bin/mysql -u root -p 进入
4、更改密码
use mysql
update user set authentication_string = password(“新密码”) where user=”root”;
flush privileges;