Start a conversation

Moving Tables from One MySQL Database to Another Using Command Line Interface

Moving all of the tables from one MySQL database to another is very easy. It can be done using phpMyAdmin to dump the database to a .sql file. However, in this tutorial, we are going to dump the database to a .sql file using the command line interface. With the command line, you can complete your task faster compare to the phpMyAdmin method.

In order to start, you need to be a user who has full privileges in both the databases or should be a root user. Usually, it is not necessary to use username and password when dumping a MySQL database in Linux cPanel Hosting. It won’t prompt you for the password and automatically takes the username and password. Follow the below steps:

How to Dump the MySQL Database to an SQL file

Enter the following command to dump a database:

mysqldump database_name > Database_name.sql

For example, suppose you wanted to dump a database called “eicrablog”.

mysqldump eukblog > eicrablog.sql

Now, since you have the database backup ready, simply import the contents to your destination database (i.e. another database).

mysql new_database_name < Database_name.sql

Here we are going to use the new destination database known as “neweicrablog”.

For Example:

mysql neweicrablog < eicrablog.sql

Once the transfer is completed, you will see two databases that are similar, but with different names.

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Diya Ahmed

  2. Posted
  3. Updated

Comments