Mysql – the ‘Debian way’ of installing multiple MySQL instances on a single server

debianMySQL

Do you know any 'Debian way' of setting up multiple MySQL instances on a single server? The server would receive data replicated from multiple remote databases.

I could use scripts like mysqlsandbox but I prefer to stick to Debian packages and would like to be able to upgrade the setup without much complications in the future. Another solution is mysqlmanager – it works with MySQL 5.1 but it's deprecated and not released anymore with 5.5.

So what's the 'best practice' of running multiple MySQL instances on a single Debian server?

Best Answer

I believe it's as simple as running mysqld_multi and setting up your my.cnf correctly. mysqld_multi is a part of the mysql distribution - not a packaged frill.

There is a patch to make /usr/share/mysql/mysqld_multi.server appropriate for use in /etc/init.d and another patch to make mysqld_multi use files in /etc/mysql/conf.d.

You can initialize MySQL data directories for new instances with the mysql_install_db command like this:

mysql_install_db --datadir=/var/lib/mysql2

Don't forget to change the root password of the newly created instance:

mysqladmin --port 3307 --user=root password 'new-password'