MySQL Utilities

5.24 mysqlserverclone — Clone Existing Server to Create New Server

This utility enables you to clone an existing MySQL server instance to create a new server instance on the same host. The utility creates a new datadir (--new-data), and, on Unix systems, starts the server with a socket file. You can optionally add a password for the login user account on the new instance.

If the user does not have read and write access to the folder specified by the --new-data option, the utility issues an error.

Similarly, if the folder specified by --new-data exists and is not empty, the utility does not delete the folder and issues an error message. Users must specify the --delete-data option to permit the utility to remove the folder prior to starting the cloned server.

The utility does not copy any data. It merely creates a new running instance of the cloned server with the same options (or additional options if specified). Thus, to create a copy of a server, you must copy the data after the server is cloned.


mysqlserverclone accepts the following command-line options:


The following command demonstrates how to create a new instance of a running server, set the root user password and enable binary logging:

shell> mkdir /source/test123
shell> mysqlserverclone --server=root:pass@localhost \
    --new-data=/Users/cbell/source/test123 --new-port=3310 \
    --root-password=pass --mysqld=--log-bin=mysql-bin
# Cloning the MySQL server running on localhost.
# Creating new data directory...
# Configuring new instance...
# Locating mysql tools...
# Setting up empty database and mysql tables...
# Starting new instance of the server...
# Testing connection to new instance...
# Success!
# Setting the root password...
# ...done.


Should the server fail to start due to an error in the server startup sequence, the utility presents an error message along with suggestions for how to identify the error. The best way to find the error is to run the utility again with verbosity turned on (using the -vvv option). This displays all of the messages from the server setup. Examine this list to find the exact error/reason why the server did not start.


The user must have permission to read all databases. Since we are using the root account for these examples (and you typically would), permissions are not generally a problem.

You also need permissions to create the new data directory and write data to it.