找回root密码--Mysql5.6.36

系统环境:

[root@db02 ~]# uname -m
x86_64
[root@db02 ~]# uname -r
2.6.32-696.el6.x86_64
[root@db02 ~]# cat /etc/redhat-release 
CentOS release 6.9 (Final)

skip-grant-tables   启动过程当中跳过受权表mysql

在这种模式下,能够无密码登陆,和受权相关的命令没法使用sql

操做过程:

# 中止正在运行的mysql
/etc/init.d/mysqld stop

# 启动mysql
/application/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking &
# 使用--skip-networking是为了禁止用户经过网络登陆,此时无密登陆,仅让本身无密登陆进行设置密码

# 进入mysql进行操做
# 将root密码改成123456
mysql> use mysql;
mysql> update user set password=PASSWORD('123456') where user='root' and host='localhost';
mysql> flush privileges;

重启mysql网络

/etc/init.d/mysqld restart

在登陆时使用新密码进行登陆mysqlapp

注:读者根据自身的状况进行修改用户的密码,并不单单是root用户,此博文仅供参考!spa

相关文章
相关标签/搜索