Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.