Setting up muliple instances of mysql using mysqlmanager
1. Create a new copy of the /etc/mysql/my.cnf file called my2.cnf. The new file should have the following configurations.
[client]
port = 3307
socket = /var/run/mysqld2/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld2/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld2/mysqld.pid
socket = /var/run/mysqld2/mysqld.sock
port = 3307
basedir = /usr
datadir = /var/lib/mysql2
tmpdir = /tmp>
2. Create copy of /var/lib/mysql to /var/lib/mysql2 (data dir)
mkdir mysql2; cp -a mysql/* mysql2
3. create /var/run/mysqld2 dir. should be owned by mysql. (where pid and sock files are)
chown mysql:mysql /var/run/mysqld2
4. Then call mysqlmanager with the defaults file. Best to just modify the /etc/init.d/mysql2 file as a shell script and call directly!
mysqlmanager --defaults-file=/etc/mysql/my2.cnf --log=/var/log/mysqlmanager.log --pid-file=/var/run/mysqld2/mysqld.pid --angel-pid-file=/var/run/mysqld2/mysqlmanager.angel.pid --run-as-service --user=mysql
*create the mysqlmanager.log file.
sudo touch /var/log/mysqlmanager.log
sudo chown mysql:mysql mysqlmanager.log
5. Login to your new instance. Must specify new port and sock file.
root@slave:# mysql -P 3307 --socket=/var/run/mysqld2/mysqld.sock -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 61
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)
6. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>
Now connect to the new host from ‘mytop’ to monitor your instance.
mytop -d mysql -P 3307 -S /var/run/mysqld2/mysqld.sock -u root -pPASSHERE
Rinse and repeat for additional mysql instances!
souce: http://www.ducea.com/2009/01/19/running-multiple-instances-of-mysql-on-the-same-machine/