A
A
Alexey Volodin2014-05-30 23:52:38
PHP
Alexey Volodin, 2014-05-30 23:52:38

PHP/MySQL (VDS CentOS) - How to connect to a remote server?

Good afternoon. Faced the problem of connecting PHP scripts to a remote MySQL server.
There is a VDS with Apache + PHP + MySQL installed, there is a script that should connect to a database on a remote server.

<?php
mysql_connect("vh**.spaceweb.ru", "someuser", "pwd");
?>

But when connecting, it gives a rather strange error:
PHP Warning:  mysql_connect(): Access denied for user 'someuser'@'23.252.*.*' (using password: YES) in /var/www/html/test.php on line 3

Those. it turns out that PHP ignores that I told it which host to connect to, and it tries to connect to the local MySQL server with the login and password for the remote one.
I tried to prescribe mysql.default_host in php.ini, but to no avail.
Maybe someone can suggest a solution to this issue.
UPD: in SSH
# mysql --host="vh**.spaceweb.ru" --user="someuser" --password='pwd'
gives the same error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shaks, 2014-05-31
@alexeyvolodin

ERRORS TO READ!
> But when connected, it gives a rather strange error:
Access denied for user 'someuser'@'23.252.*.*'
What is strange, access is denied for a user of such and such from such and such an IP. If the login/pass is correct, then it is logical to assume that the problem is in the IP. This means that on the side of the server to which you want to connect, you need to allow calls from your IP.
How to do this is another question, I'll give you a tip - dev.mysql.com/doc/refman/5.0/en/server-options.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question