Welcome Guest, Not a member yet? Register   Sign In
Connecting CI to TWO different DB on localhost
#1

(This post was last modified: 12-09-2014, 02:28 PM by mindph.)

Hello I am new

I already wrote that question here but got no satisfying answer
http://stackoverflow.com/questions/26741...-instances

Let me describe the problem quicky.

I have an application somewhere on two servers that's not supposed to have http or php but have their mysql database.

I have a third server, that runs two instances of mysql. Both run on same host with seperate logfiles, config dirs and ports.
One runs on port 3306 the other uses 3307.
One uses /var/run/mysql/mysql.sock
The other /var/run/mysql/mysql2.sock

Now on this server I want to use CI framework to collect data from both servers and output them with json.

It works connecting to mysql instance but not the mysql2 instance.
Here is my database conf for the second server:

PHP Code:
//db1 array here..

$db['db2'] = array(
 
       'dsn'   => '',
 
       'hostname' => 'localhost',
 
       'port'     => '3307',
 
       'username' => '***',
 
       'password' => '***',
 
       'database' => 'db',
 
       'dbdriver' => 'mysqli',
 
       'dbprefix' => '',
 
       'pconnect' => FALSE,
 
       'db_debug' => TRUE,
 
       'cache_on' => FALSE,
 
       'cachedir' => '',
 
       'char_set' => 'utf8',
 
       'dbcollat' => 'utf8_general_ci',
 
       'swap_pre' => '',
 
       'autoinit' => TRUE,
 
       'encrypt' => FALSE,
 
       'compress' => FALSE,
 
       'stricton' => FALSE,
 
       'failover' => array(),
 
       'save_queries' => TRUE
); 

When I stop the first server, I get the error that it can not connect to socket '/var/run/mysqld/mysqld.sock', of course because I just stopped it. But how can I get CI to use  socket '/var/run/mysqld/mysqld2.sock' for db2 while still using mysql.sock for db1? Or do I have tell php to use TCP instead of unix socket? Because on chell I need to use --protocol=TCP to connect to the second server. How?

TIA
Reply


Messages In This Thread
Connecting CI to TWO different DB on localhost - by mindph - 12-09-2014, 11:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB