1、登录MySQL数据库
mysql -uroot -p
2、授权从任何主机都允许连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '数据库密码' WITH GRANT OPTION; #设置root账号可以远程连接
3、限制某个IP,将“%”换成IP:
GRANT ALL ON *.* to root@'%' IDENTIFIED BY '密码';
FLUSH PRIVILEGES;