/**
* 注意MySQL 默认是本机连接,如果要改成局域网访问,要修改一下设置 。 报错为(Communications link failure)
* 1、在服务器上命令行输入 $ :vim /etc/mysql/mysql.conf.d/mysqld.cnf
* 2、找到bind-address = 127.0.0.1 这一行 前面加上#;
* 3重启mysql 服务 :/etc/init.d/mysql restart (service mysql restart)
*/
String url = "jdbc:mysql://192.168.11.130:3306/JDBC_Test?useSSL=false";
String user = "root";
String password = "123456";
/**
* 用telnet 连接一下主机IP 3306 (is not allowed to connect to this MySQL server)
* 原因:你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,
* 更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
#mysql -u root -p
Enter password:
……
mysql>
mysql>update user set host = '%' where u