3

Can any body help me to get the connection url of the MySQL database on the server of phpmyadmin. I want to access the database remotely.

Please note that the database is not on my local pc hard disk.

Thank you.

Schuyler
  • 509
  • 1
  • 9
  • 19
codeofnode
  • 18,169
  • 29
  • 85
  • 142
  • Are you using any programming language to perform the task? Please be more clear. – djadmin Sep 06 '12 at 06:55
  • 1
    Well, the domain is the domain where you access phpMyAdmin. The user and password... you know them... and the port is usually 3306. Try it like this :) . – Radu Murzea Sep 06 '12 at 07:06
  • @Dheeraj : Yes i want to use the database into an Web JSP application on netbeans using hibernate... plz help. – codeofnode Sep 06 '12 at 08:18
  • @SoboLAN : I know the port is 3306. i am using as jdbc:mysql://:3306/ But still i m getting the error. and i am not able to connect database remotely. plz help. – codeofnode Sep 06 '12 at 08:19
  • what's the error you are getting on connecting through url? – thar45 Sep 06 '12 at 08:33
  • cannot establish a connection to jdbc:mysql://69.187.151.5:3306/DCQ using com.mysql.jdbc.Driver (Communications link failure  The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) – codeofnode Sep 06 '12 at 09:04

1 Answers1

2

This is the connection URL for access Phpmyadmin MySql server:

Class.forName("com.mysql.jdbc.Driver");//Set driver
connection = (Connection) DriverManager.getConnection("jdbc:mysql://db_ip:3306/dbName",user_name, password);
//Get Connection

If you got below message:

#1130 - Host 'machine name' is not allowed to connect to this MySQL server

Then you need to execute below query:

   CREATE USER 'root'@'%';

   GRANT ALL PRIVILEGES ON * . * TO 'root'@'%' ;

   GRANT ALL PRIVILEGES ON `root\_%` . * TO 'root'@'%';

This query creates the root user with all privilege and password is null.

Edit:

This is the reference may help you:

https://serverfault.com/questions/89955/unable-to-connect-to-mysql-through-jdbc-connector-through-tomcat-or-externally

Community
  • 1
  • 1
Dhinakar
  • 4,061
  • 6
  • 36
  • 68
  • I am using the url : jdbc:mysql://69.187.151.5:3306/DCQ But i am getting the error as i commented in my question. – codeofnode Sep 06 '12 at 09:06
  • I think this issues arises for mysql network permission. Refer this link [http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html] – Dhinakar Sep 06 '12 at 09:10
  • m sorry to ask silly question, but can u tell me where to execute the above query.. Plz reply.. – codeofnode Sep 06 '12 at 09:12
  • Open browser and type http://69.187.151.5/phpmyadmin. Click SQL tag. Copy and paste this query. Click Go to run. – Dhinakar Sep 06 '12 at 09:16
  • i ll be back with results with actions as you said in 2 minutes.. thanks.. :) – codeofnode Sep 06 '12 at 09:21
  • i have already a user with root.. and but have some password.. Then what query should i execute.. plz reply the query with password. – codeofnode Sep 06 '12 at 09:28
  • I think no need to execute this queries for your problem. I have attached the link with the answer. Kindly refer it. – Dhinakar Sep 06 '12 at 09:32
  • The link is quit confusing and the answer in the link says various points to check.. i am quit sure that every thing mentioned in the answer is perfect in my situation.. but yet i am getting this error.. :( – codeofnode Sep 06 '12 at 09:35
  • 1
    let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16350/discussion-between-dhina-karan-and-rambo) – Dhinakar Sep 06 '12 at 09:47