Top Nav

Setup Alternate MySQL Instance

To setup an alternate instance of MySQL listening on TCP port 3307 on a RHEL5 server follow these steps.

1. Setup a new MySQL config file.

Add a line like this:

to the “[mysqld]” section.

Edit /etc/my-3307.cnf and change:




Change the following lines:


Change server-id to a unique value:

2. Setup a new service control script.

Edit /etc/init.d/mysqld-3307 and add this line:

directly after:

so that you have:

Next change this function:


Notice that the change is to add “-c $MYCNF” to the call to “my_print_defaults”.

Finally run the following search/replace commands to fixup the program name, add defaults file to mysqld_safe call and set unique pid and subsys files:

3. Setup directories

4. Set service to start on boot

5. Start the new instance:

On the first startup you should see some output like this:

6. Set MySQL root password.

And that’s it. You now have an new instance of MySQL listening on port 3307.

Remember that you must tell the mysql command line utilities where to find the instance. For example:


Also keep in mind that by default any .my.cnf file in your home directory will be used. You may have to override settings in the .my.cnf file and explicitly provide the user and password when connecting.