简体   繁体   中英

Problem connecting to remote mysql database

I am trying to connect to a mysql db on a shared server. I am using a java application to make the connection. Problem doesn't happen when I connect to localhost db.

URL = "jdbc:mysql://SHARED HOST IP:3306/DBNAME"; 
USER = "dbUSER"; 
PASS = "dbPASS"; 

Connection conn = DriverManager.getConnection(URL, USER, PASS); 

java.sql.SQLException: Access denied for user 'DBUSER'@'mycomputersIP???' (using password: YES)

It is strange that it says denied for dbuser@ mycomputersip instead of dbuser@sharedhostIP

Is there a setting on my wireless router that is screwing things up?

your database is not configured for remote access. basically its saying your user located at your ip doesn't have permission to access the database, as opposed to your user located at the web server.

if you are using a shared hosting package, you will either need to turn this on in your admin area, or it may not be supported by your host. some hosts additionally require that externally accessible databases may not be on the web server, so your connection string would likely change as well.

There are no settings screwed up on your router. If you are trying to connect from mycomputersIP (ie the program opening the JDBC connection is on your computer), then the database will need to grant permission to 'DBUSER'@'mycomputersIP' . (In fact, that is the point of that portion of the grant string.)

Just as VeeArr said, 'DBUSER'@'mycomputersIP???' is standard. For some reason your host exposes your database but isn't allowing you to connect. There's a way in phpMyAdmin to do it under Privileges if you manage the whole database or there's an option in your control panel. If not, then you need to contact your host for guidence

The Same problem I have got earlier, Its very simple, The access has been denied by your ISP to access DB,

Raise the request to grant access, it will work.

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