+ 27

How to use another website database ?

I have more than 5 websites I wana be use website database in other website, anyone tell me how to define server or database in configuration file sorry for bad English

1st Aug 2017, 3:33 AM
Saurav Saini
Saurav Saini - avatar
4 Antworten
+ 9
make a rest api for database after that you can use that in another website if you don't know about rest api then google it use this to make rest api of MySQL Database https://www.npmjs.com/package/mysql-to-rest
3rd Aug 2017, 5:48 AM
Akash
Akash - avatar
+ 8
The other website will require their port to be open for yours to connect to. They will also need the database user to allow connections that are not just from the local machine. If you have a fairly standard LAMP set-up, this will mean opening port 3306 on the database server so outside connections can be made, and a database user setting up that will be able to connect from the outside world.
1st Aug 2017, 6:56 AM
Rajesh Rajendran
+ 7
Yes. its possible. Normally you dont put your db on distant server. You should keep the db server on same data center so you avail high speed internal network link. If your websites are in host web1 and web2 and database is in dbhost1, then in web1 and web2 connect to mysql with dbhost1 as host name. mysqli $mysqli = new mysqli("dbhost1", "user", "pass"); PDO $dbh = new PDO('mysql:dbname=dbname;host=dbhost1', "user", "pass"); Legacy mysql extension mysql_connect("dbhost1", "user", "pass"); Note: Make sure in the database user@web1 (on host web1) or user@web2 (on host web2) has access.
12th Aug 2017, 4:55 PM
fsuuaas
fsuuaas - avatar
+ 3
As Akash mentioned, it's wise to build a Rest framework, so that you will know how much load other app is taking and what Type of request are being passed between the sites. Also with that it will be easy for you when you start your 6th or next site. Easy to integrate with any technology. Easy to port to any type of app
10th Aug 2017, 6:43 PM
Karthick
Karthick - avatar