(1)连接数据库
mysql -u root -p
(2)输入密码
(3)切换数据库
use mysql;
(4)修改root用户host
update user set host = '%' where user = 'root';
(5)修改mysqld配置文件
vi /etc/mysql/mysql.conf.d/mysqld.cnf
(6)将bind-address值修改为0.0.0.0并保存
:wq
(7)重启mysql
service mysql restart