I'm new to MySQL.

I've found myself in the position of having two different versions running on one host.

I'm a little unsure of how these are working together. Do I issue >service mysqlservice 3307 start?

Where does mysql3307 come into play?

1 Answer 1


This sounds a lot like something I created back in February 2011. In fact, I placed the code for the mysqlservice script in one post : Running multiple instances on the same host (Sep 30, 2011)

The mysqlservice script is a quasi-service I created to help set up multiple mysql instances. The idea is to create

  • my.cnf for a specific port number
  • service filename to launch the service

In this case, you should see a file called /etc/init.d/mysql3307. If you do not have one, please create it. It should look like this :

# readahead:    Prereads programs required for startup into memory
# chkconfig: 2345 4 99
# description:  This service causes the programs used during startup \
#               to be loaded into memory before they are needed,\
#               thus improving startup performance

# Sanity checks.
[ -x /usr/sbin/readahead ] || exit 0

# Check for > 384 MB
#free -m | gawk '/Mem:/ {exit ($2 >= 384)?0:1}' || exit 0

# Source function library.
#. /etc/rc.d/init.d/functions

SERVICE=`${WHICH} service`

MYSQL=`${WHICH} mysql`

# See how we were called.
case "$1" in
    start)      ${SERVICE} mysqlservice ${PORT_NUMBER} start    ;;
    stop)       ${SERVICE} mysqlservice ${PORT_NUMBER} stop     ;;
    status)     ${SERVICE} mysqlservice ${PORT_NUMBER} status   ;;
    restart)    ${SERVICE} mysqlservice ${PORT_NUMBER} restart  ;;
    mycnf)      ${SERVICE} mysqlservice ${PORT_NUMBER} mycnf    ;;
    edit)       ${SERVICE} mysqlservice ${PORT_NUMBER} edit     ;;
        echo $"Usage: $0 {start|stop|restart|status|mycnf}"

After creating the file, please run

chmod +x /etc/init.d/mysql3307

Now, the service can be summoned with

service mysql3307 start

Under the hood, it will call

service mysqlservice 3307 start

You could call it that way as well. Yet, setting up /etc/init.d/mysql3307 makes the service have a name that's easy to remember.

Give it a Try !!!

CAVEAT : You have to create a my.cnf file for port 3307 called /etc/my3307.cnf

The file /etc/my3307.cnf must include

datadir=<whatever folder you have for 3307's mysql instance>

The fundamentals difference between services are

  • datadir
  • port number

You can start and stop the services independent of each other. While mysqld_multi allows you to have multiple MySQL Instances under one my.cnf via setting up mysqld groups, I created the mysqlservice quasi-service to use distinct my.cnf files for each instance. That way, you do not have to worry setting up my.cnf to know what is common to all MySQL Instances vs. what is unique to each MySQL Instance.

If you setup more than two services in this manner, you become responsible for assigning the proper amount of RAM for buffers, caches, and threads.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.