作者:落地有声800_491_431 | 来源:互联网 | 2020-09-07 02:02
mysql重置root密码的方法:1、使用servicemysqlstop停止MySQL服务;2、使用--skip-grant-tables参数进入安全模式的MySQL;3、使用update命令更新root密码即可。
mysql如何重置root密码
1、关闭 MySQL 服务器:
service mysql stop
2、进入目录,以安全模式启动 MySQL
推荐学习:《mysql入门视频》
cd /usr/local/mysql/bin
./mysqld_safe --skip-grant-tables &
注意:
可能你的系统没有 safe_mysqld 程序(Windows 或 Ubuntu操作系统) ,可以使用 mysqld:
mysqld --skip-grant-tables &
3、启动后, root 用户以空密码登录 mysql:
# mysql -u rootmysql> update mysql.user set password=PASSWORD('123456') where User='root'; # 修改密码
mysql> flush privileges; # 刷新权限
mysql> quit
4、启动 MySQL:
service mysql start
这是就可以使用新密码 123456 登录了。
如果你知道密码,可以使用以下命令:
# mysqladmin -u root -p password 新密码