title: mysql multiple instances
body: <p>I have installed one version of mysql. After this I copy the MySQL folder to a new folder called <code>mysql2</code> (to make the second instances of MySQL).</p>
  
  <p>I have changed the <code>my.cnf</code> to this:</p>
  
  <pre><code>[mysqld_multi]
  mysqld=/usr/bin/mysqld_safe
  mysqladmin=/usr/bin/mysqladmin
  log=/var/log/mysqld_multi.log
  user=multi_admin
  password=secret
  [mysqld1]
  port=3306
  datadir=/var/lib/mysql
  pid-file=/var/lib/mysql/mysql.pid
  socket=/var/lib/mysql/mysql.sock
  user=mysql
  log-error=/var/log/mysql1.err
  server-id=1
  log-bin=mysql-bin
  
  [mysqld2]
  port=3308
  datadir=/var/lib/mysql2
  pid-file=/var/lib/mysql2/mysql.pid
  socket=/var/lib/mysql2/mysql.sock
  user=mysql
  log-error=/var/log/mysql2.err
  server-id=2
  log-bin=mysql-bin
  </code></pre>
  
  <p>From <code>mysqld_multi</code> all the things about start, stop, report is ok. The problem:</p>
  
  <p>When I try from comand line: <code>mysql -P 3306</code>. It connect to the first instances. If I try: <code>mysql -P 3308</code>. The same thing.</p>
  
  <p>If I try: <code>mysql -S /.../mysql2/mysql.sock</code>. It works. The same whit first instances when I try: <code>mysql -S /.../mysql/mysql.sock</code>.</p>
  
  <p>What can I do to connect by port? Or how can I connect from PHP to second instances where in comand line I can do it only by <code>mysql.sock</code>.</p>