0

I've built an application with php mysql , and now i need it to also be accessed from other place (outside the network) both places of course will have the access to the internet . How can i share the database . i can install xampp on both networks , but the important thing is the database to be shared (synchronized). am using :

$host='192.168.2.100'; // host of the server
$user='root';
$pass='root';
mysql_connect($host,$user,$pass)

$db='my_db';
mysql_select_db($db);
pnuts
  • 58,317
  • 11
  • 87
  • 139
Moussa
  • 61
  • 10
  • What do you mean by "share the database?" Do you just want to make the PHP site accessible remotely? Do you want to allow remote connections to the database? Or are you talking about replicating the entire database on another server? Also, please [don't use `mysql_*`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php?rq=1); the `mysql_*` functions are outdated, [deprecated](http://us3.php.net/manual/en/intro.mysql.php), and insecure. Use [`MySQLi`](http://us3.php.net/manual/en/book.mysqli.php) or [`PDO`](http://us3.php.net/manual/en/intro.pdo.php) instead. – elixenide Nov 10 '15 at 05:51
  • i dont need the whole application to be on the internet , i need the mysql to be shared , i have two offices working on the same database , every person is in a different place – Moussa Nov 10 '15 at 05:54
  • So, again, what exactly do you want? Do you want people in office A and office B to have *direct access* to the database (without the PHP application)? Or do you want them both to have access to the PHP application and use it to access the database? What is the relevance of PHP to this question? – elixenide Nov 10 '15 at 05:55
  • If you can tell me the both ways it would be great mr Ed Cottrell , But in my situation i need just direct access to the database (without the php application) – Moussa Nov 10 '15 at 05:58
  • i will install the php applications on both computers and i will just make the database to be accessed to the offices , i chosed this way , because i think its more easier , but if you see that accessing the whole application is a better idea i will stick to it – Moussa Nov 10 '15 at 06:00
  • 1
    Direct database access is a really bad idea, unless everyone to whom you're giving remote access is a developer. It's *much* better to give people access to the PHP application and give *it* access to the database. In any case, it sounds like your question is about changing server settings, in which case your question really belongs on [the DBA site](http://dba.stackexchange.com), not this one. – elixenide Nov 10 '15 at 06:01
  • thank you mr. Ed Cottrel i will try to find the answer there – Moussa Nov 10 '15 at 06:07
  • Be aware that the old mysql_* extension which you're using is deprecated in version 5.5 of PHP (the current version) and is being removed from version 7 (the next version). You need migrate over to using either the mysqli_* extension or PDO – SpacePhoenix Nov 10 '15 at 07:33
  • in simplied, you just need to use GRANT command to a specific ip. etc server b is in 192.168.1.212 then _GRANT ALL ON my_db.* TO root@'192.168.1.212' IDENTIFIED BY 'root_password'_ – David Nov 22 '15 at 02:13

0 Answers0