Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying mysql databases from one computer to another

Tags:

I want to copy my mysql database from my computer to another computer. How can I do this?

like image 665
Homen Avatar asked Mar 17 '14 05:03

Homen


People also ask

Can you copy a MySQL database?

To copy a MySQL database, you need to follow these steps: First, create a new database using CREATE DATABASE statement. Second, export all the database objects and data of the database from which you want to copy using mysqldump tool. Third, import the SQL dump file into the new database.


2 Answers

How to copy Mysql database from one Computer to another / backup database using mysqldump

  1. We can transfer a MySQL database from one PC to another PC using mysqldump command.

  2. We have to create dump file of database to transfer database from one PC to another PC.

  3. MySQL database is not portable database i.e. we cannot transfer it from one PC to another PC by copying and pasting it.

  4. We can use following method to transfer database.

  5. Creating a dumpfile from database/ Taking backup of MySQL database:

  6. Open command prompt.

  7. Execute following commands to change directory

>c:  “press enter”  >cd  program files/MySQL/MySQL Server 5.1/ bin “press enter”  >mysqldump -u root  -p database_name > database_name.sql  “press enter”    Enter password: password of MySQL 

Copy sql file and paste it in PC where you want to transfer database.

      2. Dumping sql file into database:-        - Open MySQL  command line client command prompt.        - Execute following command to create database. 

create database database_name;

“press enter” Database name is must as that of your database_name.

Copy that sql file into location “c:/program files/MySQL/MySQL Server 5.1/bin”

      *- Now open command prompt and execute following commands.*           >C: “press enter”          >cd program files/MySQL/MySQL Server5.1/bin “press enter”          >mysql –u root –p database_name < database_name.sql “press enter”          Your database is created on PC.          Now in MySQL command prompt check your database.   

Another one:1

This best and the easy way is to use a db tools(SQLyog)

http://www.webyog.com/product/downloads

With this tools you can connect the 2 databases servers and just copy one database on server a to server b.

For more info

http://faq.webyog.com/content/12/32/en/mysql-5-objects-are-greyed-out-in-copy-db-to-other-host-dialogue.html

look here

Another one:2

For a database named "lbry", try this:

mysqldump -u root -p lbry > dump-lbry.sql 

Create a database of the same name ("lbry" in this example) on the computer to which you wish to copy the database contents

Then import it:

mysql -u root -p lbry < dump-lbry.sql 
like image 182
jmail Avatar answered Sep 18 '22 15:09

jmail


You can do by this process step-by-step using MySQL WorkBench.

  1. Install MySQL Workbench
  2. Connect to existing Database
  3. Go to Navigator -> Management -> Data Export. (this will dump queries of tables one by one in a separate folder, Workbench uses the same folder to import)
  4. Create Database on target PC.
  5. Connect to Target Database (would consist of 0 tables in DB)
  6. Go to Navigator -> Management -> Data Import/Restore. (this will use the dump folder and create tables in your target Database).

Hope this helps.

like image 22
Abhilab-Systematix Avatar answered Sep 18 '22 15:09

Abhilab-Systematix