0

I am using the mysqli_connect($host, $user, $pass, $db) line to connect to another server through php. I am trying to write to a MySQL database.

I have used the server's IP [A.B.C.D] on the $host variable. However I cannot write to that database, and the script does not run completely.

I am using the root user and password to connect, and the user list in phpmyadmin shows that anyhost(%), 127.0.0.1 and localhost can connect with the root username (I think that's what it means). Anyway, as I am using root, I don't think this is a user privilege problem.

I have tried putting a # before 'bind-address=127.0.0.1'.

I have tried editing my.cnf according to suggestions from a lot of forums.

I have not installed firewall in any of the servers that I'm using, so unless Debian 7 64-bit comes with pre-installed firewall that blocks certain ports, I don't think that is the problem either.

Isn't there an easy way to establish connection between multiple servers? :-/

1 Answer 1

1

Your remote mysql server must accept remote connection from your IP address.

After you make this setup you can access remote mysql server like this:

mysqli_connect($remote_host, $remote_user, $pemote_pass, $remote_db);
Sign up to request clarification or add additional context in comments.

8 Comments

How do I make sure that it accepts remote connections? I've found somewhere that I have to edit /etc/phpmyadmin/config.inc.php file. But what are the exact changes that I need to make? Also, do I edit this file on the local machine? Or the remote machine? I'm really confused!
here you have a complete tutorial how to do that. debianhelp.co.uk/remotemysql.htm
Remote server is your "other server". you have to edit that my.cnf file to accept connection from your ip.
I tried to follow your debianhelp.co.uk link and my mysql will not restart! Kill me now !!!! >.< Is xampp easier to manage? I've got Access Forbidden error when I installed XAMPP. I don't know which way to go.. lol..
Solved the slow connection. In my remote server--> # nano /etc/mysql/my.cnf... under the [mysqld] section added the line--> skip-name-resolve I love this community! :D
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.