Monday, 22 February 2016

Running multiple instances of MySQL on same machine


This is article 1 of 3 for a MySQL test strategy.

Inspiration came from this blog article Installing Multiple MySQL on Same Machine.

This was done on a Windows 7 platform with MySQL 5.6, the gist of it should work on other versions and platforms.

There is no need to install the MySQL binaries again (unless of course you'd like the additional instance(s) to run a different version of MySQL).

We simply need to make a copy of the data files and ensure there are no clashes with the exisiting instance

Find the data directory.  On my machine it's C:\ProgramData\MySQL\MySQL Server 5.6.
  1. Make a copy of the my.ini file and call it something different, for example, my2.ini
  2. Make a copy of the data folder and call it something different, for example, data2
  3. Edit the my2.ini file*:
    a) correct any paths to the folder above
    b) update the log files
    c) update server-id
    d) update port x2
  4. Copy the mysql folder and its contents from original data folder to your new data folder.  Note: I don't fully understand the ramifications of this and therefore these instructions should be treated with extreme caution and not used on a production system.
  5. Install a new windows service for this instance: mysqld --install MySQL56_2 --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my2.ini"

* for the record, my settings changed as followed:
[client]
port=3306 -> 3307
[mysqld]
port=3006 -> 3307
datadir="C:/ProgramData/MySQL/MySQL Server 5.6/data2" ->  "C:/ProgramData/MySQL/MySQL Server 5.6/data2"
general_log_file="XXX.log" -> "XXX2.log"
slow_query_log_file="
XXX-slow.log" -> "XXX2-slow.log"
log-error="XXX.err" -> "XXX2.err"
server-id=1 -> 2

I don't think server-id is a default setting, but it's helpful if you're going to be running replication (if not you may not need it).

No comments:

Post a Comment