dannail
dannail

Reputation: 455

How to transfer my MySQL database to another computer?

I am using XAMPP package in my own desktop with Window 7 as OS.

That means I'm using MySQL DB and Apache server.

Now I would like to copy/migrate my whole MySQL DB to my friend's desktop, which is also with Window as OS, and also using XAMPP package.

Is there any way for me to do that?

Upvotes: 23

Views: 82342

Answers (6)

Xahed Kamal
Xahed Kamal

Reputation: 2223

Given solutions didn't work for me. These are the steps solved my problem -

  1. copy xampp/mysql/data/ibdata1 from old installation to new installation
  2. copy all databases folders except mysql, performance_schema, phpmyadmin from xampp/mysql/data and put them in new installation

Hope it helps.

Upvotes: 1

johnshen64
johnshen64

Reputation: 3884

The datadir defaults to something like C:\Program Files\MySQL\MySQL Server 5.0\data

You can just zip that folder and unzip it in the new server (with mysql server shut down in both servers) in the same place, and start mysql server there. This assumes that your datadir setting is the same in both servers.

Upvotes: 0

Hashim Aziz
Hashim Aziz

Reputation: 6185

A.Aleem11's answer will technically work but is a little too cautious and copies files over that don't contain any data or config information and are only relevant for the previous installation.

The answer is actually a lot simpler:

  1. Make sure Apache and MySQL are turned off

  2. In your new XAMPP installation, delete the mysql\data and mysql\backup folders

  3. Copy the mysql\data and mysql\backup folders in your old XAMPP installation to the new installation

  4. (Optional) If you have any config files in your old mysql folder (files that end in the .cfg extension and have the gear icon), copy these too. Chances are that if your MySQL installation is relatively recent you will have none of these, config files seem to be relied on less in modern versions.

  5. Turn Apache and MySQL back on and navigate to localhost/PHPMyAdmin to confirm that all your database tables are present

Upvotes: 2

A.Aleem11
A.Aleem11

Reputation: 1974

Copy database files from MySQL folder (under old xampp folder) except share,bin, and script folder see attached image to see which files need copy (only files with in green box) and replace all these database files in new installed xampp directory in MySQL folder.

Restart xampp start MySQL and open database and table to make sure its working.

Files to replace in green lines

Upvotes: 60

ma cılay
ma cılay

Reputation: 739

Yes. You can use the command line tool mysqldump

Saving your database

mysqldump -u[yourusername] -p[yourpassword] --all-databases > mydump.sql

Reading it back in:

mysql -u[yourusername] -p[yourpassword] < mydump.sql

I'm assuming the mysql bin directory is accessible via command line. [yourusername] and [yourpassword] should be written without the brackets.

Upvotes: 10

naser
naser

Reputation: 4437

go to this address http://127.0.0.1/ and next phpmyadmin select database and click in export and select column ... and click on go

copy file to server and goto phpmyadmin in server and click on import and add file database and enjoy it .

Upvotes: 4

Related Questions