{"id":239488,"date":"2021-07-30T16:30:06","date_gmt":"2021-07-30T23:30:06","guid":{"rendered":"https:\/\/virtual-dba.com\/?p=239488"},"modified":"2023-04-11T13:56:08","modified_gmt":"2023-04-11T20:56:08","slug":"how-to-clone-mysql-instance-on-same-server","status":"publish","type":"post","link":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/","title":{"rendered":"How to Clone a MySQL Instance on the Same Server"},"content":{"rendered":"\n<p>In this tutorial, I will go over the steps to clone your MySQL instance on the same server. This tutorial will only cover the steps to accomplish a clone on a Linux server. To ensure you do not cause corruption to the existing MySQL instance you will need to ensure that all files, logs, etc. are run in a completely different directory as the initial instance. And then when you start up the cloned instance it will need to point to the new directory locations. Failure to do this will cause instability and can inflict corruption in the initial instance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-areas-that-you-will-learn-about-in-this-tutorial-include\">Areas that you will learn about in this tutorial include:<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Starting and stopping MySQL<\/li>\n\n\n\n<li>Editing the MySQL configuration file<\/li>\n\n\n\n<li>Locations of important MySQL files<\/li>\n\n\n\n<li>Knowledge of MySQL file ownership and permissions<\/li>\n\n\n\n<li>Common MySQL environment variables<\/li>\n\n\n\n<li>Common cnf variables<\/li>\n\n\n\n<li>What is the UUID and auto.cnf file<\/li>\n\n\n\n<li>How to copy or move the data directory<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-the-following-steps-are-required-to-clone-a-mysql-8-0-instance-on-the-same-server-on-ubuntu-18-linux\">The following steps are required to clone a MySQL 8.0 instance on the same server on Ubuntu 18\/Linux:<\/h3>\n\n\n\n<p>1. Shutdown the MySQL database instance<\/p>\n\n\n\n<p>Most likely if you are on a Linux server your MySQL instance is started and stopped using systemctl (ubuntu). First, find the current status of the present MySQL instance running on your server. If the instance is up and running then you need to shut down the instance before cloning it.<\/p>\n\n\n<p><code>systemctl status MySQL<br>\nsystemctl stop mysql<\/code><\/p>\n\n\n<p>Check to ensure no running processes:<\/p>\n\n\n<p><code>ps xa |grep mysql<\/code><\/p>\n\n\n<p>Next, locate the my.cnf file and all options files used and ensure you know and understand all the file locations. As they will all need to be different for the cloned instance. It is not uncommon to have a few different conf files for your instance. Therefore, you must do some discovery efforts to see where all the file destinations are as well as port\/socket\/PID information and locations.<\/p>\n\n\n\n<p>On most Linux servers you can run the &#8216;locate&#8217; command to find the full path of a file.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>locate my.cnf &#8212; this file may redirect you to the actual .cnf file,! includedir to search specific directories for option files<\/li>\n\n\n\n<li>locate mysql.cnf &#8212; this file may redirect you to the actual .cnf file, !includedir to search specific directories for option files<\/li>\n\n\n\n<li>locate mysqld.cnf<\/li>\n\n\n\n<li>locate mylogin.cnf &#8212; if this does not exist then nothing to do here, otherwise you will need to handle<\/li>\n\n\n\n<li>locate mysqld-auto.cnf &#8212; if this does not exist then nothing to do here, otherwise you will need to handle<\/li>\n<\/ul>\n\n\n\n<p>View the .cnf files to obtain the information to find all directories referenced.<\/p>\n\n\n\n<p>Your directories may differ from what was on my system. Some of the config files may just include a pointer to another file or options directory.<\/p>\n\n\n\n<p><strong>NOTE<\/strong>: any files to be found and included using the !includedir directive on Unix operating systems must have file names ending in .cnf<\/p>\n\n\n<p><code>vi \/etc\/mysql\/mysql.cnf<br>\nvi \/etc\/mysql\/conf.d\/mysql.cnf<br>\nvi \/etc\/mysql\/my.cnf<br>\nvi \/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/code><\/p>\n\n\n<p>On my Ubuntu Linux system, the \/etc\/mysql\/mysql.conf.d\/mysqld.cnf contained only the following, so this was fairly easy to identify the handful of file locations.<\/p>\n\n\n\n<p>Your configuration file may contain much more than this.<\/p>\n\n\n<p><code>[mysqld]<br>\npid-file    \t= \/var\/run\/mysqld\/mysqld.pid<br>\nsocket      \t= \/var\/run\/mysqld\/mysqld.sock<br>\ndatadir     \t= \/var\/lib\/mysql<br>\nlog-error   \t= \/var\/log\/mysql\/error.log<\/code><\/p>\n\n\n<p>Locate the current MySQL executable and base direction that it is located in. If you are just doing a clone, and not testing running different versions, then you will need to reference these executables later.<\/p>\n\n\n<p><code>locate mysqld<br>\nlocate mysqld_safe<br>\n\/usr\/bin\/mysqld_safe<br>\n\/usr\/sbin\/mysqld<\/code><\/p>\n\n\n<p>Generally, the MySQL base executables and client programs and plugins are installed to \/usr\/bin and \/user\/sbin.<\/p>\n\n\n\n<p>2. Create a new directory for the cloned instance<\/p>\n\n\n\n<p>It is advisable to use a descriptive word in the new directories that you are creating and remain consistent, example test or clone would suffice.<\/p>\n\n\n\n<p>a) Create a new config file location<\/p>\n\n\n\n<p>The current MySQL instance has the configuration files in \/ect\/mysql.<\/p>\n\n\n\n<p>As root os user:<\/p>\n\n\n<p><code>mkdir \/etc\/mysql_test<\/code><\/p>\n<p><code>cd \/etc\/mysql_test<br>\nmkdir mysql.conf.d<\/code><\/p>\n\n\n<p>Ensure the necessary ownership and permissions are as follows:<\/p>\n\n\n<p><code>owner = root<br>\nperm = drwxr-xr-x<\/code><\/p>\n\n\n<p>b) Data dir location<\/p>\n\n\n\n<p>The current MySQL instance has the database files in \/var\/lib\/mysql.<\/p>\n\n\n\n<p>as root os user:<\/p>\n\n\n<p><code>mkdir \/var\/lib\/mysql_test<br>\ncd \/var\/lib\/mysql_test<br>\nchown -R mysql:mysql \/var\/lib\/mysql_test<br>\nchmod 750 \/var\/lib\/mysql_test<br>\n<\/code><\/p>\n\n\n<p>Ensure the necessary ownership and permissions are as follows:<\/p>\n\n\n<p><code>owner = mysql<br>\nperm  = drwxr-x---<br>\n<\/code><\/p>\n\n\n<p>c) Base file location<\/p>\n\n\n\n<p>the current base file location, where the MySQL executables are located is<\/p>\n\n\n<p><code>\/usr<\/code><\/p>\n\n\n<p>We do not need to change this as we want to use the same installed version of the MySQL executables.<\/p>\n\n\n\n<p>d) Log file location<\/p>\n\n\n\n<p>The current MySQL instance has the log files in \/var\/log\/mysql.<\/p>\n\n\n\n<p>As root os user:<\/p>\n\n\n<p><code>mkdir \/var\/log\/mysql_test<br>\nchown mysql:mysql \/var\/log\/mysql_test<br>\nchmod 750 \/var\/log\/mysql_test<br>\n<\/code><\/p>\n\n\n<p>Ensure the necessary ownership and permissions are as follows:<\/p>\n\n\n<p><code>owner = mysql<br>\nperm  = drwxr-x---<br>\n<\/code><\/p>\n\n\n<p>e) Other directories, for socket and PID file<\/p>\n\n\n\n<p>The current MySQL instance has pid and socket files located in \/var\/run\/mysql.<\/p>\n\n\n\n<p>As root os user<\/p>\n\n\n<p><code>mkdir \/var\/run\/mysqld_test<br>\nchown mysql:mysql \/var\/run\/mysqld_test<br>\n<\/code><\/p>\n<p><code>Ensure the necessary ownership and permissions are as follows:<br>\nowner = mysql<br>\nperm  = drwxr-xr-x<br>\n<\/code><\/p>\n\n\n<p>Note: The files in this directory are created when the MySQL instances startup, so nothing will need to be copied here.&nbsp;Likewise, when the MySQL instance is down there should not be any files in this directory for the PID and socket files.<\/p>\n\n\n\n<p>3. Copy all files to the new directory<\/p>\n\n\n\n<p>a) Configuration files<\/p>\n\n\n<p><code>cp -a \/etc\/mysql\/. \/etc\/mysql_test<\/code><\/p>\n<p><code>\/etc\/mysql\/conf.d\/ - contains options file, empty directory<br>\n\/etc\/mysql\/mysql.conf.d\/ - contains options file so you do want to copy all files from this directory to the new directory<br>\ncp -a \/etc\/mysql\/mysql.conf.d\/. \/etc\/mysql_test\/mysql.conf.d<br>\n<\/code><\/p>\n\n\n<p>b) Database files<\/p>\n\n\n<p><code>cd \/var\/lib\/mysql<br>\ncp -a \/var\/lib\/mysql\/. \/var\/lib\/mysql_test<br>\n<\/code><\/p>\n\n\n<p>Note: -a already implies &#8211;preserve=all, that is wider than -p = &#8211;preserve=mode,ownership,timestamps.<\/p>\n\n\n\n<p>c) Log files<\/p>\n\n\n<p><code>cd \/var\/log\/mysql<br>\ncp -a \/var\/log\/mysql\/. \/var\/log\/mysql_test<br>\n<\/code><\/p>\n\n\n<p>Remember, we are not going to run a different MySQL version so we do not need a new base directory.  Likewise, we do not need to copy the PID or socket files from the original instance as those files are removed upon shutdown of the instance.<\/p>\n\n\n\n<p>The following command is also helpful to ensure all the ownership and permissions are set appropriately:<\/p>\n\n\n<p><code>\/usr\/sbin\/mysqld --initialize --user=mysql --datadir=\/var\/lib\/mysql_test<\/code><\/p>\n\n\n<p>4. Edit the configuration file for the CLONE .cnf files only<\/p>\n\n\n\n<p>a) First start by ensuring all directory references are edited to the new directory locations<\/p>\n\n\n<p><code>vi \/etc\/mysql_test\/my.cnf<br>\n!includedir \/etc\/mysql_test\/mysql.conf.d\/<br>\ncp \/etc\/mysql_test\/my.cnf \/etc\/mysql_test\/mysql.cnf<\/code><\/p>\n<p><code>vi \/etc\/mysql_test\/mysql.conf.d\/mysqld.cnf<br>\n[mysqld]<br>\npid-file    \t= \/var\/run\/mysqld_test\/mysqld_test.pid<br>\nsocket      \t= \/var\/run\/mysqld_test\/mysqld_test.sock<br>\ndatadir     \t= \/var\/lib\/mysql_test<br>\nlog-error   \t= \/var\/log\/mysql_test\/test_error.log<\/code><\/p>\n<p><code>port=3308<br>\ntmpdir=\/var\/lib\/mysql_test<br>\nserver_id=10<br>\nShare-memory-base-name=test<br>\n<\/code><\/p>\n\n\n<p>Notice that there are a few additions on the cloned configuration file. First of all, if the original instance uses the default port 3306 for TCP connections then we must assign a new port for the clone connections to use. Next, by default, the first MySQL instance installed on a Linux server assumes the server_id of 1. So, we need to set a unique server id for the clone instance. As best practice, you should also set unique tmpdir and share-memory-base-name parameters so all resources are unique for the clone instance.<\/p>\n\n\n\n<p>Save changes to the .cnf file<\/p>\n\n\n\n<p>Examples of several other options that must have different values for each server instance<\/p>\n\n\n<p><code>--port=port_num set any port other than the default original instance, the firewall may need to be modified for this new port<br>\n--socket={file_name|pipe_name}<br>\n--pid-file=file_name  set to a file name and location other than the default original instance<br>\n<\/code><\/p>\n\n\n<p>If you use the following log file options, their values must differ for each server:<\/p>\n\n\n<p><code>--log-error[=file_name]<br>\n--log-bin[=file_name]<br>\n--general_log_file=file_name<br>\n--slow_query_log_file=file_name<\/code><\/p>\n<p><code><br>\n<\/code><\/p>\n<p><code>--tmpdir=dir_name<br>\n<\/code><\/p>\n\n\n<p>Only need to change the basedir if you are running two different versions of MySQL on the same server, that setup is outside the scope of this tutorial.<\/p>\n\n\n<p><code>--basedir=dir_name<\/code><\/p>\n\n\n<p>NOTE: Default options are read from the following .cnf files in order, so be sure to account for all of the cnf files when analyzing the initial instance settings.<\/p>\n\n\n\n<p>In my environment I do not have a file in \/etc\/my.cnf.<\/p>\n\n\n<p><code>\/etc\/my.cnf \/etc\/mysql\/my.cnf ~\/. my.cnf<\/code><\/p>\n\n\n<p>5. Create separate OS Linux environment variables for the cloned instance, this way when you use MySQL client programs you point to the correct files<\/p>\n\n\n\n<p>It is best practice to create the environment variable file in your home directory, for the user that will start up the clone instance and connect to MySQL client programs.<\/p>\n\n\n\n<p>In my case, it is the root user<\/p>\n\n\n<p><code>cd<br>\nvi mysql_test.env<\/code><\/p>\n<p><code><br>\n<\/code><\/p>\n<p><code>MYSQL_HOME=\/etc\/mysql_test<br>\nUSER=mysql<br>\nMYSQL_UNIX_PORT=\/var\/run\/mysqld_test\/mysqld_test.sock<br>\nMYSQLX_UNIX_PORT=\/var\/run\/mysqld_test\/mysqldx_test.sock<br>\nMYSQL_TCP_PORT=3308<br>\nexport MYSQL_HOME USER MYSQL_UNIX_PORT MYSQL_TCP_PORT MYSQLX_UNIX_PORT<br>\n<\/code><\/p>\n\n\n<p>6. Create the error log file as an empty file to ensure not errors during startup<\/p>\n\n\n<p><code>vi \/var\/log\/mysql_test\/test_error.log<br>\nchown mysql:mysql \/var\/log\/mysql_test\/test_error.log<br>\nchmod 775 \/var\/log\/mysql_test\/test_error.log<\/code><\/p>\n\n\n<p>7. Handle the UUID and auto.cnf file<\/p>\n\n\n\n<p>You can start the server for each installation using the command bin\/mysqld_safe under its corresponding base directory. The mysqld_safe determines the proper &#8211;basedir option to pass to mysqld, and you need specify only the &#8211;socket and &#8211;port options to mysqld_safe. You should also specify the &#8211;defaults-file option file to use for start up.<\/p>\n\n\n\n<p>For the first time starting up the clone you need to be aware of the auto.cnf file and its purpose. When starting mysqld, the MySQL server automatically obtains a UUID. This is a Universal Unique Identifier that sets up the server_uuid parameter and basically is used for replication. If an auto.cnf file is found in the datadir then that UUID is used. Therefore, for the cloned instance be sure to rename the auto.cnf in the copied over new directory as you want a new UUID assigned for the clone instance. If the startup process does not find the auto.cnf file it will auto-generate a new one. You do NOT need to manually create this file.<\/p>\n\n\n<p><code>cd \/var\/lib\/mysql_test<br>\nmv auto.cnf auto.cnf. Backup<\/code><\/p>\n\n\n<p>8. Startup the cloned instance<\/p>\n\n\n\n<p>You should now be ready to start the cloned instance.<\/p>\n\n\n\n<p>Start by setting the env variables to point to clone test instance:<\/p>\n\n\n<p><code>. mysql_test.env<\/code><\/p>\n\n\n<p>To start up the cloned instance I am using the mysqld_safe program. To ensure the startup uses the new cnf, database files, and logfiles I must specify the file that I defined those configuration options.  Additionally, I include the user option so the MySQL instance runs as the os user MySQL. The last character &#8216;&amp;&#8217; ensures the mysqld daemon will run in the background so that I do not need to keep my session open.<\/p>\n\n\n<p><code>\/usr\/bin\/mysqld_safe --defaults-file=\/etc\/mysql_test\/my.cnf --user=mysql &amp;<\/code><\/p>\n\n\n<p>9. Sanity test that the clone MySQL instance is now running and users can log in and use the database<\/p>\n\n\n\n<p>Test your user logins to the new clone system.<\/p>\n\n\n<pre><code>root@ubuntu01:\/var\/log\/mysql_test# mysql -uroot -p --socket=\/var\/run\/mysqld_test\/mysqld_test.sock\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or g.\nYour MySQL connection id is 8\nServer version: 8.0.25 MySQL Community Server - GPL\n \nCopyright (c) 2000, 2021, Oracle and\/or its affiliates.\n \nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n \nType 'help;' or 'h' for help. Type 'c' to clear the current input statement.\n \nmysql&gt; show databases;\n+--------------------+\n| Database       \t|\n+--------------------+\n| db1            \t|\n| information_schema |\n| mysql          \t|\n| performance_schema |\n| sys            \t|\n| test           \t|\n+--------------------+\n6 rows in set (0.01 sec)\n \nmysql&gt; SHOW VARIABLES LIKE '%datadir%';\n+---------------+----------------------+\n| Variable_name | Value            \t|\n+---------------+----------------------+\n| datadir   \t| \/var\/lib\/mysql_test\/ |\n+---------------+----------------------+\n1 row in set (0.00 sec)\n<\/code><\/pre>\n\n\n<p>The cloned instance is now up and running and usable. To start up your original MySQL instance you should get out of your ssh session and start a new one so the environment variables are reset. Then start up your original MySQL instance as usual. If all steps were done properly you should now see two instances of MySQL running. Be sure to log into the client programs appropriately. For the original instance, you can log into client MySQL programs as usual. However, for the cloned instance be sure you pass the appropriate socket and\/or port. You should set the clone\/test environment variables as well, before starting\/stopping the database instance or using the MySQL client programs such as MySQL shell or mysqldump.<\/p>\n\n\n\n<p>This tutorial should have provided you with enough information so that you too can clone your MySQL instance and run it simultaneously on the same server, without affecting the original instance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, I will go over the steps to clone your MySQL instance on the same server. This tutorial will only cover the steps to accomplish a clone on a Linux server. To ensure you do not cause corruption to the existing MySQL instance you will need to ensure that all files, logs, etc. [&hellip;]<\/p>\n","protected":false},"author":38,"featured_media":239495,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"<!-- wp:paragraph -->\n<p>In this tutorial, I will go over the steps to clone your MySQL instance on the same server. This tutorial will only cover the steps to accomplish a clone on a Linux server. To ensure you do not cause corruption to the existing MySQL instance you will need to ensure that all files, logs, etc. are run in a completely different directory as the initial instance. And then when you start up the cloned instance it will need to point to the new directory locations. Failure to do this will cause instability and can inflict corruption in the initial instance.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading -->\n<h2 id=\"h-areas-that-you-will-learn-about-in-this-tutorial-include\">Areas that you will learn about in this tutorial include:<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:list -->\n<ul><li>Starting and stopping MySQL<\/li><li>Editing the MySQL configuration file<\/li><li>Locations of important MySQL files<\/li><li>Knowledge of MySQL file ownership and permissions<\/li><li>Common MySQL environment variables<\/li><li>Common cnf variables<\/li><li>What is the UUID and auto.cnf file<\/li><li>How to copy or move the data directory<\/li><\/ul>\n<!-- \/wp:list -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3 id=\"h-the-following-steps-are-required-to-clone-a-mysql-8-0-instance-on-the-same-server-on-ubuntu-18-linux\">The following steps are required to clone a MySQL 8.0 instance on the same server on Ubuntu 18\/Linux:<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>1. Shutdown the MySQL database instance<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Most likely if you are on a Linux server your MySQL instance is started and stopped using systemctl (ubuntu). First, find the current status of the present MySQL instance running on your server. If the instance is up and running then you need to shut down the instance before cloning it.<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>systemctl status MySQL<br>\nsystemctl stop mysql<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Check to ensure no running processes:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>ps xa |grep mysql<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Next, locate the my.cnf file and all options files used and ensure you know and understand all the file locations. As they will all need to be different for the cloned instance. It is not uncommon to have a few different conf files for your instance. Therefore, you must do some discovery efforts to see where all the file destinations are as well as port\/socket\/PID information and locations.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>On most Linux servers you can run the 'locate' command to find the full path of a file.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:list -->\n<ul><li>locate my.cnf -- this file may redirect you to the actual .cnf file,! includedir to search specific directories for option files<\/li><li>locate mysql.cnf -- this file may redirect you to the actual .cnf file, !includedir to search specific directories for option files<\/li><li>locate mysqld.cnf<\/li><li>locate mylogin.cnf -- if this does not exist then nothing to do here, otherwise you will need to handle<\/li><li>locate mysqld-auto.cnf -- if this does not exist then nothing to do here, otherwise you will need to handle<\/li><\/ul>\n<!-- \/wp:list -->\n\n<!-- wp:paragraph -->\n<p>View the .cnf files to obtain the information to find all directories referenced.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Your directories may differ from what was on my system. Some of the config files may just include a pointer to another file or options directory.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p><strong>NOTE<\/strong>: any files to be found and included using the !includedir directive on Unix operating systems must have file names ending in .cnf<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>vi \/etc\/mysql\/mysql.cnf<br>\nvi \/etc\/mysql\/conf.d\/mysql.cnf<br>\nvi \/etc\/mysql\/my.cnf<br>\nvi \/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>On my Ubuntu Linux system, the \/etc\/mysql\/mysql.conf.d\/mysqld.cnf contained only the following, so this was fairly easy to identify the handful of file locations.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Your configuration file may contain much more than this.<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>[mysqld]<br>\npid-file    \t= \/var\/run\/mysqld\/mysqld.pid<br>\nsocket      \t= \/var\/run\/mysqld\/mysqld.sock<br>\ndatadir     \t= \/var\/lib\/mysql<br>\nlog-error   \t= \/var\/log\/mysql\/error.log<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Locate the current MySQL executable and base direction that it is located in. If you are just doing a clone, and not testing running different versions, then you will need to reference these executables later.<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>locate mysqld<br>\nlocate mysqld_safe<br>\n\/usr\/bin\/mysqld_safe<br>\n\/usr\/sbin\/mysqld<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Generally, the MySQL base executables and client programs and plugins are installed to \/usr\/bin and \/user\/sbin.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>2. Create a new directory for the cloned instance<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>It is advisable to use a descriptive word in the new directories that you are creating and remain consistent, example test or clone would suffice.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>a) Create a new config file location<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The current MySQL instance has the configuration files in \/ect\/mysql.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>As root os user:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>mkdir \/etc\/mysql_test<\/code><\/p>\n<p><code>cd \/etc\/mysql_test<br>\nmkdir mysql.conf.d<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Ensure the necessary ownership and permissions are as follows:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>owner = root<br>\nperm = drwxr-xr-x<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>b) Data dir location<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The current MySQL instance has the database files in \/var\/lib\/mysql.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>as root os user:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>mkdir \/var\/lib\/mysql_test<br>\ncd \/var\/lib\/mysql_test<br>\nchown -R mysql:mysql \/var\/lib\/mysql_test<br>\nchmod 750 \/var\/lib\/mysql_test<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Ensure the necessary ownership and permissions are as follows:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>owner = mysql<br>\nperm  = drwxr-x---<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>c) Base file location<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>the current base file location, where the MySQL executables are located is<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>\/usr<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>We do not need to change this as we want to use the same installed version of the MySQL executables.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>d) Log file location<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The current MySQL instance has the log files in \/var\/log\/mysql.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>As root os user:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>mkdir \/var\/log\/mysql_test<br>\nchown mysql:mysql \/var\/log\/mysql_test<br>\nchmod 750 \/var\/log\/mysql_test<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Ensure the necessary ownership and permissions are as follows:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>owner = mysql<br>\nperm  = drwxr-x---<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>e) Other directories, for socket and PID file<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The current MySQL instance has pid and socket files located in \/var\/run\/mysql.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>As root os user<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>mkdir \/var\/run\/mysqld_test<br>\nchown mysql:mysql \/var\/run\/mysqld_test<br>\n<\/code><\/p>\n<p><code>Ensure the necessary ownership and permissions are as follows:<br>\nowner = mysql<br>\nperm  = drwxr-xr-x<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Note: The files in this directory are created when the MySQL instances startup, so nothing will need to be copied here.&nbsp;Likewise, when the MySQL instance is down there should not be any files in this directory for the PID and socket files.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>3. Copy all files to the new directory<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>a) Configuration files<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>cp -a \/etc\/mysql\/. \/etc\/mysql_test<\/code><\/p>\n<p><code>\/etc\/mysql\/conf.d\/ - contains options file, empty directory<br>\n\/etc\/mysql\/mysql.conf.d\/ - contains options file so you do want to copy all files from this directory to the new directory<br>\ncp -a \/etc\/mysql\/mysql.conf.d\/. \/etc\/mysql_test\/mysql.conf.d<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>b) Database files<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>cd \/var\/lib\/mysql<br>\ncp -a \/var\/lib\/mysql\/. \/var\/lib\/mysql_test<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Note: -a already implies --preserve=all, that is wider than -p = --preserve=mode,ownership,timestamps.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>c) Log files<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>cd \/var\/log\/mysql<br>\ncp -a \/var\/log\/mysql\/. \/var\/log\/mysql_test<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Remember, we are not going to run a different MySQL version so we do not need a new base directory.  Likewise, we do not need to copy the PID or socket files from the original instance as those files are removed upon shutdown of the instance.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The following command is also helpful to ensure all the ownership and permissions are set appropriately:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>\/usr\/sbin\/mysqld --initialize --user=mysql --datadir=\/var\/lib\/mysql_test<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>4. Edit the configuration file for the CLONE .cnf files only<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>a) First start by ensuring all directory references are edited to the new directory locations<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>vi \/etc\/mysql_test\/my.cnf<br>\n!includedir \/etc\/mysql_test\/mysql.conf.d\/<br>\ncp \/etc\/mysql_test\/my.cnf \/etc\/mysql_test\/mysql.cnf<\/code><\/p>\n<p><code>vi \/etc\/mysql_test\/mysql.conf.d\/mysqld.cnf<br>\n[mysqld]<br>\npid-file    \t= \/var\/run\/mysqld_test\/mysqld_test.pid<br>\nsocket      \t= \/var\/run\/mysqld_test\/mysqld_test.sock<br>\ndatadir     \t= \/var\/lib\/mysql_test<br>\nlog-error   \t= \/var\/log\/mysql_test\/test_error.log<\/code><\/p>\n<p><code>port=3308<br>\ntmpdir=\/var\/lib\/mysql_test<br>\nserver_id=10<br>\nShare-memory-base-name=test<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Notice that there are a few additions on the cloned configuration file. First of all, if the original instance uses the default port 3306 for TCP connections then we must assign a new port for the clone connections to use. Next, by default, the first MySQL instance installed on a Linux server assumes the server_id of 1. So, we need to set a unique server id for the clone instance. As best practice, you should also set unique tmpdir and share-memory-base-name parameters so all resources are unique for the clone instance.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Save changes to the .cnf file<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Examples of several other options that must have different values for each server instance<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>--port=port_num set any port other than the default original instance, the firewall may need to be modified for this new port<br>\n--socket={file_name|pipe_name}<br>\n--pid-file=file_name  set to a file name and location other than the default original instance<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>If you use the following log file options, their values must differ for each server:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>--log-error[=file_name]<br>\n--log-bin[=file_name]<br>\n--general_log_file=file_name<br>\n--slow_query_log_file=file_name<\/code><\/p>\n<p><code><br>\n<\/code><\/p>\n<p><code>--tmpdir=dir_name<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>Only need to change the basedir if you are running two different versions of MySQL on the same server, that setup is outside the scope of this tutorial.<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>--basedir=dir_name<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>NOTE: Default options are read from the following .cnf files in order, so be sure to account for all of the cnf files when analyzing the initial instance settings.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>In my environment I do not have a file in \/etc\/my.cnf.<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>\/etc\/my.cnf \/etc\/mysql\/my.cnf ~\/. my.cnf<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>5. Create separate OS Linux environment variables for the cloned instance, this way when you use MySQL client programs you point to the correct files<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>It is best practice to create the environment variable file in your home directory, for the user that will start up the clone instance and connect to MySQL client programs.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>In my case, it is the root user<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>cd<br>\nvi mysql_test.env<\/code><\/p>\n<p><code><br>\n<\/code><\/p>\n<p><code>MYSQL_HOME=\/etc\/mysql_test<br>\nUSER=mysql<br>\nMYSQL_UNIX_PORT=\/var\/run\/mysqld_test\/mysqld_test.sock<br>\nMYSQLX_UNIX_PORT=\/var\/run\/mysqld_test\/mysqldx_test.sock<br>\nMYSQL_TCP_PORT=3308<br>\nexport MYSQL_HOME USER MYSQL_UNIX_PORT MYSQL_TCP_PORT MYSQLX_UNIX_PORT<br>\n<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>6. Create the error log file as an empty file to ensure not errors during startup<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>vi \/var\/log\/mysql_test\/test_error.log<br>\nchown mysql:mysql \/var\/log\/mysql_test\/test_error.log<br>\nchmod 775 \/var\/log\/mysql_test\/test_error.log<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>7. Handle the UUID and auto.cnf file<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>You can start the server for each installation using the command bin\/mysqld_safe under its corresponding base directory. The mysqld_safe determines the proper --basedir option to pass to mysqld, and you need specify only the --socket and --port options to mysqld_safe. You should also specify the --defaults-file option file to use for start up.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>For the first time starting up the clone you need to be aware of the auto.cnf file and its purpose. When starting mysqld, the MySQL server automatically obtains a UUID. This is a Universal Unique Identifier that sets up the<a href=\"http:\/\/mysql.babo.ist\/replication-options.html#sysvar_server_uuid\" target=\"_blank\" rel=\"noreferrer noopener\"> server_uuid<\/a> parameter and basically is used for replication. If an auto.cnf file is found in the datadir then that UUID is used. Therefore, for the cloned instance be sure to rename the auto.cnf in the copied over new directory as you want a new UUID assigned for the clone instance. If the startup process does not find the auto.cnf file it will auto-generate a new one. You do NOT need to manually create this file.<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>cd \/var\/lib\/mysql_test<br>\nmv auto.cnf auto.cnf. Backup<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>8. Startup the cloned instance<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>You should now be ready to start the cloned instance.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Start by setting the env variables to point to clone test instance:<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>. mysql_test.env<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>To start up the cloned instance I am using the mysqld_safe program. To ensure the startup uses the new cnf, database files, and logfiles I must specify the file that I defined those configuration options.  Additionally, I include the user option so the MySQL instance runs as the os user MySQL. The last character '&amp;' ensures the mysqld daemon will run in the background so that I do not need to keep my session open.<\/p>\n<!-- \/wp:paragraph -->\n\n<p><code>\/usr\/bin\/mysqld_safe --defaults-file=\/etc\/mysql_test\/my.cnf --user=mysql &amp;<\/code><\/p>\n\n<!-- wp:paragraph -->\n<p>9. Sanity test that the clone MySQL instance is now running and users can log in and use the database<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Test your user logins to the new clone system.<\/p>\n<!-- \/wp:paragraph -->\n\n<pre><code>root@ubuntu01:\/var\/log\/mysql_test# mysql -uroot -p --socket=\/var\/run\/mysqld_test\/mysqld_test.sock\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or g.\nYour MySQL connection id is 8\nServer version: 8.0.25 MySQL Community Server - GPL\n \nCopyright (c) 2000, 2021, Oracle and\/or its affiliates.\n \nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n \nType 'help;' or 'h' for help. Type 'c' to clear the current input statement.\n \nmysql&gt; show databases;\n+--------------------+\n| Database       \t|\n+--------------------+\n| db1            \t|\n| information_schema |\n| mysql          \t|\n| performance_schema |\n| sys            \t|\n| test           \t|\n+--------------------+\n6 rows in set (0.01 sec)\n \nmysql&gt; SHOW VARIABLES LIKE '%datadir%';\n+---------------+----------------------+\n| Variable_name | Value            \t|\n+---------------+----------------------+\n| datadir   \t| \/var\/lib\/mysql_test\/ |\n+---------------+----------------------+\n1 row in set (0.00 sec)\n<\/code><\/pre>\n\n<!-- wp:paragraph -->\n<p>The cloned instance is now up and running and usable. To start up your original MySQL instance you should get out of your ssh session and start a new one so the environment variables are reset. Then start up your original MySQL instance as usual. If all steps were done properly you should now see two instances of MySQL running. Be sure to log into the client programs appropriately. For the original instance, you can log into client MySQL programs as usual. However, for the cloned instance be sure you pass the appropriate socket and\/or port. You should set the clone\/test environment variables as well, before starting\/stopping the database instance or using the MySQL client programs such as MySQL shell or mysqldump.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>This tutorial should have provided you with enough information so that you too can clone your MySQL instance and run it simultaneously on the same server, without affecting the original instance.<\/p>\n<!-- \/wp:paragraph -->","_et_gb_content_width":"","content-type":"","footnotes":""},"categories":[4166,39],"tags":[20],"class_list":["post-239488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-mysql","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.1 (Yoast SEO v27.1.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Clone a MySQL Instance on the Same Server<\/title>\n<meta name=\"description\" content=\"This tutorial will cover how to clone your MySQL instance on the same server. These steps will only cover how to clone on a linux server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Clone a MySQL Instance on the Same Server\" \/>\n<meta property=\"og:description\" content=\"This tutorial will cover how to clone your MySQL instance on the same server. These steps will only cover how to clone on a linux server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual-DBA Remote DBA Services &amp; Support - Certified Database Experts\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-30T23:30:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-11T20:56:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"557\" \/>\n\t<meta property=\"og:image:height\" content=\"291\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Cheryl Bryll\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@virtual_dba\" \/>\n<meta name=\"twitter:site\" content=\"@virtual_dba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cheryl Bryll\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/\"},\"author\":{\"name\":\"Cheryl Bryll\",\"@id\":\"https:\/\/virtual-dba.com\/#\/schema\/person\/fa0ae91d91b6287541c2fec3169ab1bd\"},\"headline\":\"How to Clone a MySQL Instance on the Same Server\",\"datePublished\":\"2021-07-30T23:30:06+00:00\",\"dateModified\":\"2023-04-11T20:56:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/\"},\"wordCount\":1660,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/virtual-dba.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg\",\"keywords\":[\"linux\"],\"articleSection\":[\"Blog\",\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/\",\"url\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/\",\"name\":\"How to Clone a MySQL Instance on the Same Server\",\"isPartOf\":{\"@id\":\"https:\/\/virtual-dba.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg\",\"datePublished\":\"2021-07-30T23:30:06+00:00\",\"dateModified\":\"2023-04-11T20:56:08+00:00\",\"description\":\"This tutorial will cover how to clone your MySQL instance on the same server. These steps will only cover how to clone on a linux server.\",\"breadcrumb\":{\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage\",\"url\":\"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg\",\"contentUrl\":\"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg\",\"width\":557,\"height\":291,\"caption\":\"How to Clone a MySQL Instance on the Same Server\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtual-dba.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Clone a MySQL Instance on the Same Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtual-dba.com\/#website\",\"url\":\"https:\/\/virtual-dba.com\/\",\"name\":\"Virtual-DBA Remote DBA Services &amp; Support - Certified Database Experts\",\"description\":\"Remote Database Administration\",\"publisher\":{\"@id\":\"https:\/\/virtual-dba.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtual-dba.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/virtual-dba.com\/#organization\",\"name\":\"Virtual-DBA: Remote DBA | Remote Database Administration\",\"alternateName\":\"Virtual-DBA powered by XTIVIA\",\"url\":\"https:\/\/virtual-dba.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtual-dba.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/virtual-dba.com\/wp-content\/uploads\/V-DBA-Database-Services-and-Support-Featured-Logo.jpg\",\"contentUrl\":\"https:\/\/virtual-dba.com\/wp-content\/uploads\/V-DBA-Database-Services-and-Support-Featured-Logo.jpg\",\"width\":557,\"height\":291,\"caption\":\"Virtual-DBA: Remote DBA | Remote Database Administration\"},\"image\":{\"@id\":\"https:\/\/virtual-dba.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/virtual_dba\",\"https:\/\/www.linkedin.com\/showcase\/36220649\/\",\"https:\/\/www.youtube.com\/channel\/UCx3AIeUQ2ziTLKZSJDZ-SEg\"],\"description\":\"Eliminate database downtime and spiraling costs with XTIVIA\u2019s Virtual-DBA. In today\u2019s always-on business world, gaps in 24x7 on-call DBA support, neglected maintenance and security, or a stretched team struggling with overwhelming workloads can lead to costly disruptions and threaten business continuity. XTIVIA\u2019s Virtual-DBA provides the immediate, expert database administration you need, exactly when you need it, ensuring optimal performance, ironclad security, and significant cost savings without the burden of expanding your in-house team. The goal of Virtual-DBA is to provide a cost-effective solution for organizations seeking to optimize the security, management, maintenance, availability, and performance of their critical business systems, whether self-managed or cloud-managed (e.g., AWS RDS, Azure SQL Database). We accomplish this through a comprehensive remote DBA service offering designed specifically to meet the Oracle\u00ae, DB2\u00ae, Informix\u00ae, MySQL\u2122, PostgreSQL\u00ae, MongoDB\u00ae, MariaDB, and Microsoft SQL Server\u00ae, CockroachDB, Databricks, AWS, and Azure needs of our clients.\",\"email\":\"info@xtivia.com\",\"telephone\":\"8886853101\",\"legalName\":\"XTIVIA, Inc\",\"foundingDate\":\"1992-05-01\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"201\",\"maxValue\":\"500\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtual-dba.com\/#\/schema\/person\/fa0ae91d91b6287541c2fec3169ab1bd\",\"name\":\"Cheryl Bryll\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtual-dba.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5a2c4a2b6132262488d3550966c3827dfcbad921136695096285fc903e6a76be?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5a2c4a2b6132262488d3550966c3827dfcbad921136695096285fc903e6a76be?s=96&d=mm&r=g\",\"caption\":\"Cheryl Bryll\"},\"url\":\"https:\/\/virtual-dba.com\/author\/cheryl-lei-bryll\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Clone a MySQL Instance on the Same Server","description":"This tutorial will cover how to clone your MySQL instance on the same server. These steps will only cover how to clone on a linux server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/","og_locale":"en_US","og_type":"article","og_title":"How to Clone a MySQL Instance on the Same Server","og_description":"This tutorial will cover how to clone your MySQL instance on the same server. These steps will only cover how to clone on a linux server.","og_url":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/","og_site_name":"Virtual-DBA Remote DBA Services &amp; Support - Certified Database Experts","article_published_time":"2021-07-30T23:30:06+00:00","article_modified_time":"2023-04-11T20:56:08+00:00","og_image":[{"width":557,"height":291,"url":"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg","type":"image\/jpeg"}],"author":"Cheryl Bryll","twitter_card":"summary_large_image","twitter_creator":"@virtual_dba","twitter_site":"@virtual_dba","twitter_misc":{"Written by":"Cheryl Bryll","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#article","isPartOf":{"@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/"},"author":{"name":"Cheryl Bryll","@id":"https:\/\/virtual-dba.com\/#\/schema\/person\/fa0ae91d91b6287541c2fec3169ab1bd"},"headline":"How to Clone a MySQL Instance on the Same Server","datePublished":"2021-07-30T23:30:06+00:00","dateModified":"2023-04-11T20:56:08+00:00","mainEntityOfPage":{"@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/"},"wordCount":1660,"commentCount":0,"publisher":{"@id":"https:\/\/virtual-dba.com\/#organization"},"image":{"@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage"},"thumbnailUrl":"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg","keywords":["linux"],"articleSection":["Blog","MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/","url":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/","name":"How to Clone a MySQL Instance on the Same Server","isPartOf":{"@id":"https:\/\/virtual-dba.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage"},"image":{"@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage"},"thumbnailUrl":"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg","datePublished":"2021-07-30T23:30:06+00:00","dateModified":"2023-04-11T20:56:08+00:00","description":"This tutorial will cover how to clone your MySQL instance on the same server. These steps will only cover how to clone on a linux server.","breadcrumb":{"@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#primaryimage","url":"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg","contentUrl":"https:\/\/virtual-dba.com\/wp-content\/uploads\/How-to-Clone-a-MySQL-Instance-on-the-Same-Server.jpg","width":557,"height":291,"caption":"How to Clone a MySQL Instance on the Same Server"},{"@type":"BreadcrumbList","@id":"https:\/\/virtual-dba.com\/blog\/how-to-clone-mysql-instance-on-same-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtual-dba.com\/"},{"@type":"ListItem","position":2,"name":"How to Clone a MySQL Instance on the Same Server"}]},{"@type":"WebSite","@id":"https:\/\/virtual-dba.com\/#website","url":"https:\/\/virtual-dba.com\/","name":"Virtual-DBA Remote DBA Services &amp; Support - Certified Database Experts","description":"Remote Database Administration","publisher":{"@id":"https:\/\/virtual-dba.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtual-dba.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/virtual-dba.com\/#organization","name":"Virtual-DBA: Remote DBA | Remote Database Administration","alternateName":"Virtual-DBA powered by XTIVIA","url":"https:\/\/virtual-dba.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtual-dba.com\/#\/schema\/logo\/image\/","url":"https:\/\/virtual-dba.com\/wp-content\/uploads\/V-DBA-Database-Services-and-Support-Featured-Logo.jpg","contentUrl":"https:\/\/virtual-dba.com\/wp-content\/uploads\/V-DBA-Database-Services-and-Support-Featured-Logo.jpg","width":557,"height":291,"caption":"Virtual-DBA: Remote DBA | Remote Database Administration"},"image":{"@id":"https:\/\/virtual-dba.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/virtual_dba","https:\/\/www.linkedin.com\/showcase\/36220649\/","https:\/\/www.youtube.com\/channel\/UCx3AIeUQ2ziTLKZSJDZ-SEg"],"description":"Eliminate database downtime and spiraling costs with XTIVIA\u2019s Virtual-DBA. In today\u2019s always-on business world, gaps in 24x7 on-call DBA support, neglected maintenance and security, or a stretched team struggling with overwhelming workloads can lead to costly disruptions and threaten business continuity. XTIVIA\u2019s Virtual-DBA provides the immediate, expert database administration you need, exactly when you need it, ensuring optimal performance, ironclad security, and significant cost savings without the burden of expanding your in-house team. The goal of Virtual-DBA is to provide a cost-effective solution for organizations seeking to optimize the security, management, maintenance, availability, and performance of their critical business systems, whether self-managed or cloud-managed (e.g., AWS RDS, Azure SQL Database). We accomplish this through a comprehensive remote DBA service offering designed specifically to meet the Oracle\u00ae, DB2\u00ae, Informix\u00ae, MySQL\u2122, PostgreSQL\u00ae, MongoDB\u00ae, MariaDB, and Microsoft SQL Server\u00ae, CockroachDB, Databricks, AWS, and Azure needs of our clients.","email":"info@xtivia.com","telephone":"8886853101","legalName":"XTIVIA, Inc","foundingDate":"1992-05-01","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"201","maxValue":"500"}},{"@type":"Person","@id":"https:\/\/virtual-dba.com\/#\/schema\/person\/fa0ae91d91b6287541c2fec3169ab1bd","name":"Cheryl Bryll","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtual-dba.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5a2c4a2b6132262488d3550966c3827dfcbad921136695096285fc903e6a76be?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5a2c4a2b6132262488d3550966c3827dfcbad921136695096285fc903e6a76be?s=96&d=mm&r=g","caption":"Cheryl Bryll"},"url":"https:\/\/virtual-dba.com\/author\/cheryl-lei-bryll\/"}]}},"_links":{"self":[{"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/posts\/239488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/comments?post=239488"}],"version-history":[{"count":0,"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/posts\/239488\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/media\/239495"}],"wp:attachment":[{"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/media?parent=239488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/categories?post=239488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtual-dba.com\/wp-json\/wp\/v2\/tags?post=239488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}