系统环境:
[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 /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
在登录时使用新密码进行登录mysql
注:读者根据自身的情况进行修改用户的密码,并不仅仅是root用户,此博文仅供参考!