23

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?

yivi
  • 42,438
  • 18
  • 116
  • 138
dannail
  • 455
  • 2
  • 10
  • 27

5 Answers5

54

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

Abdelsalam Shahlol
  • 1,621
  • 1
  • 20
  • 31
A.Aleem11
  • 1,844
  • 17
  • 12
  • 1
    Just what I was looking for, also add that, if windows dialog box comes up asking you if to replace some files with the same name, just click yes and continue. and also don't forget to stop MySQL and Apache and restart them. – Kingston Fortune Jun 07 '19 at 12:12
  • awesome! But can't we backup only specific a database ? – Ahmed Sohel Nov 13 '19 at 04:40
10

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.

ma cılay
  • 749
  • 1
  • 6
  • 19
4

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 .

naser
  • 4,373
  • 4
  • 18
  • 13
1

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

Hashim Aziz
  • 4,074
  • 5
  • 38
  • 68
0

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.

yivi
  • 42,438
  • 18
  • 116
  • 138
johnshen64
  • 3,734
  • 1
  • 21
  • 17