[root@skywalking-java1 ~]# systemctl stop mysqld
[root@skywalking-java1 ~]# vim /etc/my.cnf
[mysqld]
skip-grant-tables #添加这行
[root@skywalking-java1 ~]# systemctl restart mysqld
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
3 rows in set (0.00 sec)
update mysql.user set authentication_string=password('a^X1wIKwskU0D6Li') where user='root' and host='%';
update mysql.user set authentication_string=password('a^X1wIKwskU0D6Li') where user='root' and host='localhost';
FLUSH PRIVILEGES;
grant all privileges on *.* to'root'@'localhost' identified by 'a^X1wIKwskU0D6Li';
grant all privileges on *.* to'root'@'%' identified by 'a^X1wIKwskU0D6Li';
FLUSH PRIVILEGES;
可能用到的问题
mysql> grant all privileges on *.* to'root'@'localhost' identified by 'a^X1wIKwskU0D6Li';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to'root'@'localhost' identified by 'a^X1wIKwskU0D6Li';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
修改密码成功后,退出,再进行关掉数据库,去掉上述添加的那行