Mysql5.7忘记root密码及mysql5.7修改root密码的方法
kevin.Zhu 发布于:2014-2-9 0:08 分类:Mysql 有 24 人浏览,获得评论 0 条
关闭正在运行的 MySQL :
1 |
[root@www.woai.it ~]# service mysql stop |
运行
1 |
[root@www.woai.it ~]# mysqld_safe --skip-grant-tables & |
为了安全可以这样禁止远程连接:
1 |
[root@www.woai.it ~]# mysqld_safe --skip-grant-tables --skip-networking & |
使用mysql连接server:
1 |
[root@www.woai.it ~]# mysql -p |
更改密码:
1 |
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost'; |
*特别提醒注意的一点是,新版的mysql数据库下的user表中已经没有Password字段了
而是将加密后的用户密码存储于authentication_string字段
1 2 |
mysql> flush privileges; mysql> quit; |
修改完毕。重启