请问centos7上的mysql忘记密码怎么办

img

删了重新安装

修改 my.cnf 文件
在[mysqld]的段中增加参数:skip-grant-tables #跳过数据库权限验证
然后重启mysql服务、 直接登录
登录后修改用户密码

配置文件中加上 skip-grant-tables
vim /etc/my.cnf
[mysqld]
skip-grant-tables

重新mysql服务
service mysqld restart
免密直接登录
mysql -u root
MySQL [(none)]> use mysql;
Database changed
MySQL [mysql]> update user set authentication_string=password('xinmima') where user='root';
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1

MySQL [mysql]>