title: CodeIgniter: Connecting two mysql instances
body: <p>I want to use two database instances in my CodeIgniter application. I have set up db1 and db2 in the application but it always uses the socket of the first database.</p>
  
  <pre><code>$this-&gt;db2 = $this-&gt;load-&gt;database('db2', TRUE);
  
  Message: mysqli::real_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  </code></pre>
  
  <p>but the second server runs on '/var/run/mysqld/mysqld2.sock'
  I can not see where to tell it to use the second socket.</p>
  
  <p>Please note that I still want to connect to the first database too, I need to merge two replications, so setting defalut socket in php.ini is not an option.</p>