简体   繁体   中英

How to connect with remote MySQL database?

so I tried to connect to my local host with the 3306 port, and it works fine. Now, I'm using my second computer to connect to the database remotely.

  1. I use the jdbc:mysql://192.168.15.25:3306/yourdatabase type.
  2. My two computers are actually using the same IP.
  3. The trace says communication failure. I followed the problem, and it happens when I try to get the connection from the DriverManager.
  4. I did not touch the firewall at all.
  5. I did not write any permissions to users, as there are no users, just the admin.

Two computers can't have same IP. Check the second for IP address using ifconfig command (if you have *nix system).

Follow this instructions:

Client PC:(sample ip: 192.168.0.105 want yo connect to mysql server on 192.168.0.172)
- Java app: user: dbuser, pass: dbpass, host: 192.168.0.172

Mysql Server PC:
- On mysql console: GRANT ALL PRIVILEGES ON *.* TO dbuser@192.168.0.105 identified by "dbpass";
  FLUSH PRIVILEGES;

Now you have all set to make a remote conection from your client to your mysql server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM