Organizational Research By

Surprising Reserch Topic

mysql connect to remote server using ip address using -'php,mysql'


mysql connect to remote server using ip address  using -'php,mysql'

I am using PHP and MySQL to make a database connection, the only change is that I am trying to access my remote server from my local computer using my server IP address.

mysql_connect("x.xx.xx.x","username","password") or die(mysql_error());


and the error I am getting is Unable to connect to the given host. The user has all privileges and rights.
    

asked Sep 8, 2015 by rajesh
0 votes
17 views



Related Hot Questions

4 Answers

0 votes
Most default installs of MySQL only listen to the local machine. Look for the bind-address setting in my.cnf on the server, and make sure it's listening on the IP address you're targetting. You may also need to ensure skip-networking isn't switched on! Alternatively (and less securely!) the following will set it up to listen on all addresses - local and remote: bind-address = 0.0.0.0
answered Sep 8, 2015 by rajesh
0 votes
1) Check which interface MySQL listen for connections, local (localhost, 127.0.0.1) or remote (0.0.0.0 or IP address). It's in my.cnf. http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html 2) Check does your user have corresponding privileges. User that logs in from localhost can have different priveleges from remote one. For example 'user'@'localhost' and 'user'@'%'
answered Sep 8, 2015 by rajesh
0 votes
Try to add a user (USER-NAME) allowed to connect from the IP: mysql> GRANT ALL PRIVILEGES ON *.* TO USER-NAME@IP IDENTIFIED BY "PASSWORD"; USER-NAME is the username that you would like to create (like 'widor') IP is the public IP address of your remote connection (like '195.x.y.z') Of course, limit the privileges you want to grant (ALL PRIVILEGES is probably not your choice)
answered Sep 8, 2015 by rajesh
0 votes
Before you try using PHP todo this. Open up your terminal or console and type the following: $ mysql -u username -h x.xx.xx.x -p then enter your password Or on windows then type: \path\to\mysql.exe -u username -h x.xx.xx.x -p then enter your password This will give you a more detailed response as to the authentication issue that's coming up. And you can be 100% sure that your remote login from your IP address works. If it works fine then its something in your PHP code that you're missing.
answered Sep 8, 2015 by rajesh

...