Copy a database to another MySQL instance


We want to copy a whole database along with its tables and data to another MySQL instance.

The database is called bank_development.

In the source machine

mysqldump -u root -p bank_development > ayo.sql

Take the file ayo.sql to the target machine.

In the target machine

Start the MySQL client from the same folder with ayo.sql.

mysql -u root -p

Create the database schema,

CREATE DATABASE bank_development;

use it,

use bank_development;

and make the actual migration.

source ./ayo.sql

That’s it!

Review

This is a comfortable way for a developer to move/copy/backup his database.

2 Responses to Copy a database to another MySQL instance

  1. halim says:

    very nice

  2. Alex says:

    Thanks! That works!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: