Thursday, February 23, 2012

Installing Multiple Mysql on same Machine

It took me lot of time figuring out how to install multiple mysql instances on same machine.
So I thought of sharing Process for setting up multiple Mysql on same machine will be useful for somebody looking for such manual...

1. Install Mysql server on that machine
2. Create a folder called xyz anywhere.
3. Create 2-3 folders...say data1, data2 etc inside xyz folder...they will hold the data for respective tables of respective installation.
4. Create 3 files my1.ini, my2.ini, my3.ini inside xyz folder.
5. Find out my.ini of your original Mysql server installation. And copy the content into all 3 ini files.
6. Modify following configurations in all 3 ini files according to your convenience. Here is example..
# password = your_password
port = 3307
socket = "C:/xampp/mysql/mypipe1"
port= 3307
socket = "C:/xampp/mysql/mypipe1"
server-id = 1
innodb_data_home_dir = "C:/mysql1/data1"
innodb_log_group_home_dir = "C:/mysql1/data1"

Each ini file will contain respective unique entry for port, datadir, socket, server-id etc..
7. Copy mySqlInstallationFolder/mysql/data/mysql folder into all 3 folders data1, data2 and data3.
8. Go to comand prompt and run these commands
Mysqlpath\mysql\bin\mysqld --install mysqld1 --defaults-file=yourPath\xyz\my1.ini [ for Windows...u can find equivalent Linux command for installing a new service ]
Mysqlpath\mysql\bin\mysqld --install mysqld2 --defaults-file=yourPath\xyz\my2.ini
Mysqlpath\mysql\bin\mysqld --install mysqld3 --defaults-file=yourPath\xyz\my3.ini

9. Start your respective service ie mysqld1,mysqld2,mysqld3 [these are all different instances of mysql].
10. Login to individual mysql server using following command
mysql -u root -h localhost -P 3307 [change your port name]
mysql -u root -h localhost -P 3307 -p [ if you have password for root ]


  1. Thanks Mukesh, it works great !!

  2. which mysql version u r using?

    1. It is version independent. I suppose I might have tried for mysql 5.5 or 5.6.

  3. Did this on Windows under MySQL 5.7. For step 8 I had to enclose the path in quotes, as in: Mysqlpath\mysql\bin\mysqld --install mysqld1 --defaults-file="yourPath\xyz\my1.ini"

    For Step 10: mysql --port=3307 --host= --user=root --password