vim /etc/my.cnf  //    [mysqld]下添加参数
   [mysqld]
   skip-grant-tables

重启mysql

systemctl restart mysqld 

终端输入 msyql进入数据库

mysql>update mysql.user set authentication_string=password('新密码') where user='root' and host='localhost'