-2

I am using xampp with windows 7, and I would like to copy a MySQL databse from C:\xampp\mysql\data to another PC, because I cannot access it from phpmyadmin, knowing that old PC shutdown unexpectedly and that caused a problem.

I tried this solution but it did not work.

jkdev
  • 11,360
  • 15
  • 54
  • 77
Mahdi Miad
  • 63
  • 11

1 Answers1

1

Try this:

mysqldump -u root -p databasename > dbbackup.sql

Then to restore:

mysql -u root -p databasename < dbbackup.sql

The options are as follows.

  • -u indicates the username (here I am using root - the administrator user, but you can use another user with rights to the database)
  • -p indicates the prompt for a password (this is the password that is associated with the user you specified above). After pressing enter on the mysqldump command, you will be prompted to enter a password.
  • databasename is the name of your database of course
  • dbbackup.sql is the name of the file to save your exported database to (you can rename it to whatever you want

Notice in both commands the difference between > and <. These are redirection operators.

> indicates that you are writing to a file. < indicates you are reading from a file. You don't want to accidentally use > for the last command because you could end up writing over your backup file.

kojow7
  • 10,308
  • 17
  • 80
  • 135