469,138 Members | 1,248 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

Remote Connection To Database

196 100+
Not sure if this is where i should be posting this question but here goes anyways;

As the title indicates im trying to setup a remote connection to a database, i have added access for the remote connection; i even made a total wild card for all ip address e.g. *.*.*.* and when i tried to connect it still gives me a connection error, i cannot figure out why, i am pretty certain that the ip address on both ends is correct.

So any ideas or help would be greatly appreciated
Sep 25 '08 #1
6 2328
310 100+
For good help, try posting more information.

From what machine to what machine are you trying to make a connection? E.g. Windows to Linux, Linux to Linux, etc.

How are you trying to make the connection? From what application on the computer you are trying to connect from? For example, are you needing to use an ODBC driver for Windows?

What are your error messages?

At the same time see if you have access to any logs or anything that can give you more information. If possible, see if you can connect with the same user information from the machine where the database is located.
Sep 25 '08 #2
5,058 Expert 4TB
Note that the wildcard symbol for the host part of a MySQL user is %, not *
Expand|Select|Wrap|Line Numbers
  1. GRANT ... TO 'User'@'%'
That should allow the user to connect from anywhere.
Sep 25 '08 #3
196 100+
Ok to the first question its a linux to linux connection, i have a database on one server, on another completely seperate server i have a .php script which access the database (i know this script works becuase it works locally i.e. on the server the database is hosted on).

Now for the actual error ->

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '#.#.#.1' (4) in /home/content/a/n/g/######/html/#######/########.php on line 6
Could not connect: Can't connect to MySQL server on '#.#.#.3' (4)

Also i regards to the wildcard symbol, i did use the % symbol i just forgot.

I hope this information helps thanks
Sep 26 '08 #4
310 100+
If it is a Linux to Linux connection you are attempting, then it may be easier to debug.

Try to open up a terminal window on your "client" machine, and then try to connect to your database on the "server" machine using the mysql command line facility. I would assume you have the mysql client installed on this machine.

The synax is something like "mysql -h hostname -u username -p [databasename]" where username is the mysql username for the connection, the -p will cause the program to prompt you for the password for this username, and the hostname is the net ID of the server machine, e.g. its IP address or known network machine name. I don't think you need to supply the database name for this initially. You should be able to connect and then attempt to select the database to use afterwards.

The point is, if you cannot connect in this manner, then you are not going to be able to connect from PHP. If you cannot connect this way, you may have something blocking connection attempts, like your firewall, or you have something wrong in the username specification. Or maybe the password, since I believe the mysql console client prompts you for the password before trying to make the connection.

If you can indeed connect this way, then you can look in more detail in your PHP connection calls, as the problem then must be there.
Sep 26 '08 #5
196 100+
I don't thik i can connect using that method due to the fact im currently using remote hosting, so i don't think i can open terminal windows??

Any other ideas thanks
Sep 28 '08 #6
310 100+
I don't thik i can connect using that method due to the fact im currently using remote hosting, so i don't think i can open terminal windows??

Any other ideas thanks
Not really sure what you mean here. Are you working on a Linux machine? What do you mean by remote hosting? If, for example, you are working on a remote Linux machine from another local machine sitting in front of you, either LInux or Windows, then you can do what I suggest.

For example, if you are working on Linux remotely from Windows using a putty.exe window, then you have the window right there where you can invoke the mysql command to attempt a connection. Same actually if you are working on a remote Linux from a Linux machine. You can attempt to connect to your "server" machine database from your "client" machine database from a Linux operating system (which has the mysql client software installed on it) simply by calling the mysql command (with proper arguments as described in my previous post here) from the command line in a shell window. It does not matter whether that shell is a remote shell from a Windows of another Linux machine.

You could try the same from a Windows machine directly using a Windows command window if you have the Windows version of the mysql client installed on your Windows machine. I believe there is a Windows port.

Or perhaps I don't understand what you mean with the problem "you are using remote hosting". If your "server" machine is a Linux machine located at a remote internet provider, that does not matter at all. I have had no problem making a connection with the mysql command from my home machine to my database on my internet provider, as long as I give the correct arguments to the "host" and "username" parameters, and then provide the correct password when prompted. Again, any firewall you have on your PC must allow such a connection (maybe it does per default, but if you get stuck here, check your firewall).
Sep 29 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by GAVO-UK | last post: by
3 posts views Thread by Hrvoje Vrbanc | last post: by
5 posts views Thread by Mitya Mitriev | last post: by
2 posts views Thread by Tor Inge Rislaa | last post: by
3 posts views Thread by Me LK | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.