• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

02 7903 0216

     

Open Ticket

    

Client Area

FASTDOT Web Hosting Australia

FASTDOT Web Hosting Australia

Australian Cloud Hosting

  • Web Design
    • eCommerce Development
    • Branding
    • Web Design
  • Domains
    • Register
    • Domain FAQ
    • Domain Extensions
    • MyDNS Manager
    • Domain Transfer
  • Hosting
    • WordPress Hosting
    • Sydney cPanel Hosting
    • Magento Hosting – eCommerce Website
    • eCommerce Options
      • Managed Magento Hosting
      • PrestaShop Hosting
      • OpenCart Hosting
      • CS-Cart Hosting
    • Business Emails
  • Cloud Servers
    • VMware ESXi Hypervisor
    • Equinix – ISO Certified Data Centres
    • Cloud Hosting Info
    • Virtual Machines
  • Resources
    • Partner Program
    • Transferring Websites
    • WordPress Tips
    • Email Tutorials
    • Hosting in Australia
    • Apps Galore
    • Tutorials & News
      • SEO
      • VMware VPS Cloud
      • PHP and MySQL
      • Security
      • Linux Guides
      • Server Management
Order Now
VMware Cloud Hosting

Australian Cloud Hosting

Solid Cloud Hosting for your Websites

Compare

September 1, 2017 by Editor

MySQL DatabaseDo you want to duplicate or copy a cPanel MySQL database? This can be done using phpMyAdmin by following the steps below:

Note: It’s important that you BACKUP your database first before performing the steps below.

Login to your cPanel Account
Create a new Database with the cPanel MySql Wizard
Select the “phpMyAdmin” icon
Select the database you wish to copy from the list in the left-hand sidebar
Select the “Operations” tab
Scroll down to “Copy database to:”.
Enter the new database name using the cpanel name format (with the username_ prefixed)  and select “structure and data” to copy everything.
Check the box “Add AUTO_INCREMENT value.”
Click on the Go button to proceed.

You should now see your duplicated database in the list within the left-hand sidebar.

 

If you are not running cPanel then you can simply use the command prompt , see below:

 

MySQL Database – How To Copy a MySQL Database

Copy a MySQL database on the same server

MySQL Database

To copy a MySQL database, you need to follow these steps:

  1. First, create a new database using CREATE DATABASE statement.
  2. Second, export all the database objects and data of the database from which you want to copy using mysqldump tool.
  3. Third, import the SQL dump file into the new database.

For the demonstration, we will copy the classicmodels database to classicmodels_backup database.

Step 1. Create the classmodels_backup database:

First, log in to MySQL database server:

>mysql -u root -p
Enter password: **********

Then, use CREATE DATABASE statement as follows:

> CREATE DATABASE classicmodels_backup;

Third, use SHOW DATABASES command to verify:

> SHOW DATABASES

MySQL database server returns the following output:

+----------------------+
| Database |
+----------------------+
| classicmodels |
| classicmodels_backup |
| information_schema |
| mysql |
| performance_schema |
| sys |
+----------------------+
6 rows in set (0.00 sec)

As you see, we have created the classicmodels_backup database successfully.

Step 2. Dump database objects and data into SQL file using the mysqldump tool.

Suppose, you want to dump the database objects and data of the classicmodels database into an SQL file located at D:\db folder, here is the command:

>mysqldump -u root -p classicmodels > d:\db\classicmodels.sql
Enter password: **********

Basically, this command instructs mysqldump to log in to the MySQL server using the root user account with a password and exports the database objects and data of the classicmodels database to d:\db\classicmodels.sql. Note that the operator (>) means exporting.

Step 3. Import the d:\db\classicmodels.sql file into classicmodels_backup database.

>mysql -u root -p classicmodels_backup < d:\db\classicmodels.sql
Enter password: **********

Note that the operator ( <) means importing.

To verify the import, you can perform a quick check by using the SHOW TABLES command.

> SHOW TABLES FROM classicmodels_backup;

It returned the following output:

+--------------------------------+
| Tables_in_classicmodels_backup |
+--------------------------------+
| customers |
| employees |
| offices |
| orderdetails |
| orders |
| payments |
| productlines |
| products |
+--------------------------------+
8 rows in set (0.01 sec)

As you see, we have successfully copied all the objects and data from the classicmodels database to classicmodels_backup database.

Copy a MySQL database from a server to another

To copy a MySQL database from a server to another, you use the following steps:

  1. Export the database on the source server to a SQL dump file.
  2. Copy the SQL dump file to the destination server
  3. Import the SQL dump file to the destination server

Let’s take a look at how to copy the classicmodels database from a server to another.

First, export the classicmodels database to db.sql file.

>mysqldump -u root -p --databases classicmodels > d:\db\db.sql
Enter password: **********

Note that --database option allows mysqldump to include both CREATE DATABASE and USE statements in the SQL dump file. These statements will create the classicmodels database in the destination server and make the new database as the default database for loading the data.

In short, the following statements are included at the beginning of the SQL dump file when we use --database option.

CREATE DATABASE `classicmodels`.

USE `classicmodels`;

Third, import the db.sql file to the database server with the assumption that the db.sql file was copied to c:\tmp\ folder.

>mysql -u root -p classicmodels < c:\tmp\db.sql

In this tutorial, you have learned step by step how to copy a MySQL database on the same server and copy database from a server to another.

See our VMware Server offerings via the link below

VMware Cloud Hosting

More great articles

Security Issues with allow_url_fopen
Solving a 500 Internal Server Error
Use PHPMyAdmin script for Search and Replace in Database
What is a phpinfo file and how to create it

Category iconPHP and MySQL

Primary Sidebar

Recent Posts

  • How to Upload Files Using the cPanel File Manager?
  • How To Increase the PHP Max Upload Size in cPanel®?
  • Choosing a hosting platform in 2021
  • VARCHAR vs. TEXT for MySQL Databases
  • What Are the Best Shopify® Alternatives in 2021?
Security Issues with allow_url_fopen
How to Import and Export Large MySQL Databases via command line in CentOS
Solving a 500 Internal Server Error
How to reset the MySQL root password in CentOS via SSH

Categories

  • Application Hosting
  • Australian Cloud Hosting
  • cPanel Hosting
  • DNS and Domains
  • eCommerce Hosting
  • Email Tutorials
  • Legals
  • Linux Tutorials
  • Operating Systems
  • PHP and MySQL
  • Register a Domain Name
  • Search Engine Optimization
  • Security
  • Server Management
  • Tutorials
  • VMware Cloud Hosting
  • Web Hosting Tutorials
  • WordPress Tips & Tricks
Australian web hosting

Footer

Recent Posts

  • How to Upload Files Using the cPanel File Manager?
  • How To Increase the PHP Max Upload Size in cPanel®?
  • Choosing a hosting platform in 2021
  • VARCHAR vs. TEXT for MySQL Databases
  • What Are the Best Shopify® Alternatives in 2021?

Legals

  • Terms&Conditions
  • SLA
  • Acceptable Usage Policies
  • Privacy Policies
  • About FASTDOT
  • ISO Certified

Contact

Australia: +61 02 7903 0216
Submit a Support Ticket

Company

FASTDOT.COM.AU PTY/LTD
ACN 002 454 631
200 Bourke Rd, Alexandria NSW 2015 Australia
Processing by eWay, PayPal and Bitcoin

blankNSW Government Provider

Made with in Sydney/Australia

Copyright © 2022 FASTDOT.COM

All rights reserved. Return to top