1、mysql>use mysql;
2、mysql>update user set host = '%' where user ='root';
3、mysql>select host, user from user;
4、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //赋予任何主机访问数据的权限
5、mysql>FLUSH PRIVILEGES //修改生效
6、mysql>EXIT //退出MySQL
重启mysql
#systemctl stop mariadb
#systemctl start mariadb
如果还是不行的话,则继续
1、mysql> USE mysql;
2、mysql> UPDATE user SET plugin='' WHERE User='root';
3、mysql> FLUSH PRIVILEGES;
4、mysql> exit;
重启mysql生效。