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.)
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参数注释掉。(如果有的话)