mysql忘记root密码解决方法
警告
本文最后更新于 2020-05-30 17:09,文中内容可能已过时。
跳过mysql的TCP/IP连接方式和验证模块
需要用到两个参数:
–skip-grant-tables:跳过加载授权表(mysql.user)
–skip-networking:跳过加载网络连接(关闭通过网络连接)
(1)停数据库 systemctl stop mysqld
(2)跳过授权表启动数据库 mysqld_safe –defaults-file=/etc/my.cnf –skip-grant-tables –skip-networking &
(3)修改密码
[root@db01 mysql]mysql
[(none)]>flush privileges; [(none)]>grant all on . to root@’localhost’ identified by ‘abc’ with grant option; [root@db01 mysql]# mysqladmin -uroot -pabc shutdown [root@db01 mysql]# systemctl start mysqld
请我喝杯水

