(一).通过命令修改,具体如下:
a、停止MySQL服务
执行:/etc/init.d/mysql stop
b、跳过验证启动MySQL
/usr/local/mysql/bin/mysqld_safe –skip-grant-tables >/dev/null 2>&1 &
然后:
mysql mysql -uroot //登陆
mysql> update mysql.user set authentication_string=password('root') where user='root' ;
mysql> FLUSH PRIVILEGES;
mysql> quit
然后重新启动mysql
/etc/init.d/mysql start
(二).在/tmp/my.cnf的[mysqld]下加入skip-grant-tables ;
重启mysql服务 etc/init.d/mysql restart
mysql mysql -uroot //登陆
mysql> update mysql.user set authentication_string=password('root') where user='root' ;
mysql> FLUSH PRIVILEGES;
mysql> quit;
去掉在/tmp/my.cnf的[mysqld]下加入skip-grant-tables ;
然后重新启动mysql
/etc/init.d/mysql start
参考链接:
https://blog.csdn.net/sinat_32829963/article/details/70196355