mysql忘记root密码解决方法

修改mysql密码  会让mysql有那么几分钟处于谁都能连接的状态,衡量安全和关闭mysql外网连接端口的利弊

1.关闭mysql

[root@localhost ~]# /etc/init.d/mysqld stop
Shutting down MySQL.                                       [  OK  ]

2.跳过密码检测 启动mysql

[root@localhost bin]# ./mysqld_safe  --skip-grant-tables &
[1] 9982

3. 登录mysql 修改密码

mysql5.7版本的修改方法
update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
以前版本的修改方法:
mysql>update mysql.user set password=password('123456') where user='root' ; mysql>flush privileges ; mysql>quit

4.重启mysql

[root@localhost bin]# /etc/init.d/mysqld  stop
[root@localhost bin]# /etc/init.d/mysqld  start

 

posted @ 2018-03-29 14:02  lazyball  阅读(174)  评论(0编辑  收藏  举报