1、确定服务器上的防火墙没有阻止 3306 端口。
MySQL 默认的端口是 3306 ,需要确定防火墙没有阻止 3306 端口,否则远程是无法通过 3306 端口连接到 MySQL 的。
如果您在安装 MySQL 时指定了其他端口,请在防火墙中开启您指定的 MySQL 使用的端口号。
2、增加允许远程连接 MySQL 。
方法一:授权法
mysql -uroot -p123456
grant all PRIVILEGES on discuz.* to ted@'123.123.123.123' identified by '123456';
grant all PRIVILEGES on *.* to ted@'123.123.123.123' identified by '123456';
grant all PRIVILEGES on *.* to ted@'%' identified by '123456';
flush privileges;
让权限立即生效
点代表整个库,discuz.*代表discuz库的所有表,%代表任何地址
方法二:改表法
mysql -u root -pvmware
mysql> use mysql;
mysql> update user set host = ‘%’ where user = ‘root’;
mysql> select host, user from user;
mysql> flush privileges;