/**
* Note that MySQL default is a native connection, if you want to change to LAN access, to modify the settings. Error is (Communications link failure)
* 1, on the server command line input $:vim/etc/mysql/mysql.conf.d/mysqld.cnf
* 2, find bind-address = 127.0.0.1 this line before adding #;
* 3 Restart MySQL service:/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";
/**
* Use Telnet to connect the host IP 3306 (is not allowed to connect to thisMySQL server)
* Reason: Your account is not allowed to login from remote, only on localhost. This time, as long as the computer in localhost, after logging into MySQL,
* Change "host" in "User" table in "MySQL" Database, rename "%" from "localhost"
#mysql-u root-p Enter password: ... mysql>
Mysql>update User Set host = '% ' where user = ' root ';
Mysql>select host, user from user;
*
* +-----------+------------------+
* | Host | user |
* +-----------+------------------+
*| % | Root |
*| localhost | Debian-sys-maint |
*| localhost | mysql.session |
*| localhost | Mysql.sys |
*+-----------+------------------+
*tips: Note this time to save the exit (flush privileges;)
* Then restart MySQL (/etc/init.d/mysql restart/service mysql restart)
*
*/
The above is a modification to be made on the server
/**
* This time to connect MySQL if still unsuccessful, the server will be reported to reject the connection. Error is
* (Message from server: "Host ' 192.168.11.1 ' isn't allowed to connect to this MySQL server")
* or direct connection is successful.
* This time we're going to open the server's 3306 interface: (note Be sure to turn on the firewall and then open 3306 ports)
* 1, Firewall open 3306 port (sudo ufw allow 3306)
* 2. Turn on Firewall View status: (A, sudo ufw enable B, sudo ufw default deny)
* 3. View firewall status (sudo UFW status)
* OR View port status directly (show global variables like ' port ';)
*
*/
Tips (Tip: You can open the telent of window 10 first
In Control Panel > Programs > (Dropdown page to last) programs and features > turn on and turn off Windows features on the left > turn on telent Service)
Then (win+ R key) can use the telent way to try to spell the server port first.
Configure WINDOW10 to remotely connect to a database on a virtual machine (Mysql,redis)