Jump to content

MySQL PHP Write & Read Servers Separate


danesc

Recommended Posts

Guys,

 

I have two MySQL servers 5.0.77-log on different machines. One is the "master" and the other one is the "slave" with a replication happening real-time. Here is my question:

 

How do I configure my PHP scripts to use the Master for INSERT, UPDATE and the Slave for all SELECT statements?  My current configuration is setup to do all MySQL interactions with one server (Master) but now I want to separate the two.

 

Here is my current configuration... please help out with what the new configuration would be:

 

$database = "some_db_name";

$user = "some_username_here";

$pass = "some_password_here";

$host = "xx.xx.xx.xx";

$connection = mysql_connect( $host, $user, $pass ) or failed_connection( mysql_error() );

mysql_select_db( $database ) or failed_connection( mysql_error() );

 

 

Thank you in advance!

Link to comment
https://forums.phpfreaks.com/topic/156864-mysql-php-write-read-servers-separate/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.