本文主要向大家介绍了MySQL数据库之MySQL5.7的跳过授权表登录 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
MySQL5.7的跳过授权表登录。mysql启动时跳过授权表,使用无密码登陆,在这个会话中再把授权表加载进来,把密码修改之后重启即可。
1.关闭MySQL数据库
[root@localhost ~]# systemctl stop mysqld
Redirecting to /bin/systemctl stop mysqld.service
[root@localhost ~]# mysqld --help
[root@localhost ~]# mysqld --verbose --help >a.txt
加上--skip-grant-tables这个参数重启时,便可以跳过密码验证这个参数。
--skip-grant-tables (Start without grant tables. This gives all users FULL ACCESS to all tables.)
2.进入/etc/my.cnf配置文件把 validate_password=off参数注释掉。(如果有的话)
3.先执行 [root@localhost ~]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
([root@localhost ~]# mysqld_safe --skip-grant-tables & 当此命令没有时使用上面的命令)
[root@localhost ~]# systemctl start mysqld 来启动数据库。
4.查看数据库是否启动 netstat -tunlp | grep 3306
5.使用mysql -u root 直接进行登陆
6.等进去之后执行 mysql> flush PRIVILEGES;
7.重新设置密码 mysql> alter user 'root'@'localhost' identified by '1234567';
8.执行 mysql> flush tables; 并推出
9.重启mysql的服务并登陆。
本文由职坐标整理并发布,希望对同学们学习MySQL有所帮助,更多内容请关注职坐标数据库MySQL数据库频道!