There are basically two ways of doing this:
1, using the management tool of MySQL, can connect remotely, for example, with navigation Cat series, as long as the other IP, and then you can enter the account password to connect.
2, connect using code.
Java code example:
Packagecom.test;Importjava.sql.Connection;ImportJava.sql.DriverManager;ImportJava.sql.ResultSet;Importjava.sql.Statement; Public classdatabasetest {databasetest () {String URL= "Jdbc:mysql://10.30.11.13:3306/mysql"; Connection Db; Statement datarequest; ResultSet Results; String str; Try{ //load MySQL driverClass.forName ("Com.mysql.jdbc.Driver"); //establish a connection to MySQLDb = drivermanager.getconnection (URL, "Guest", "123456"); String Query= "SELECT * FROM Mysql.user"; //Execute SQL statementDatarequest =db.createstatement (); Results=datarequest.executequery (query); while(Results.next ()) {str=NewString (results.getstring (1)); System.out.println (str); //System.out.println ("success!");} datarequest.close (); Db.close (); }Catch(Exception e) {System.out.println ("error!" +e); return; } } Public Static voidMain (string[] args) {//TODO auto-generated Method Stub Newdatabasetest (); }}
3, 10.30.11.13 is the server IP address, MySQL is the database name, user is the database table, guest is the guest account, the first time with root is not possible, later with the guest can connect.
How do I connect MySQL data on another computer on my local computer? (code example)