Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a network of websites hosted on two different servers, server1 and server2.
I need to be able to access the data stored in a MySQL DataBase on server1 from a PHP script in a site hosted on server2.

Say a user registers on site1 on server1 and his data is inserted into the DataBase on server1. Now, that user would be able to log in on site2 on server2 with the same registration.
That would mean the PHP script on server2 needs access to the MySQL DB on server1. I don't want to copy the user data over to a DB on server2, because the user might also edit his or her user information on site1.

I'd like to be able to share this data without editing the server's data (as in http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html). So far, I haven't been able to figure out a secure way of achieving this, does anyone know how to do this using PHP (or JavaScript, but I'd prefer the system to work for everyone, regardless if JS is enabled)?

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
276 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can achieve this by allowing your other servers hostname to connect to your database.

In a MySQL command prompt or phpmyadmin execute the query:

GRANT ALL ON databasename.* TO username@'ipaddress' IDENTIFIED BY 'somepassword';

http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...