Jump to: navigation, search

MySQL Backup and Restore

From w3cyberlearnings

Contents

MySQL Backup

The mysqldump command uses to backup database or table.

Backup Database

The mysqldump to backup database.

  • user name: myuserName (-uUSERNAME)
  • password: mypassword (-pPASSWORD)
  • database: databasename
  • backup to store in mybackup_01082012.sql file in the current directory
$mysqldump -umyuserName -pmypassword databasename > mybackup_01082012.sql

Backup mysql table command line: Backup a single or multiple tables

  • database: databasename
  • table: mytable
$mysqldump -umyuserName -pmypassword databasename mytable > mybackup_01082012_table.sql

Backup mysql table command line for multiple tables

$mysqldump -umyuserName -pmypassword databasename table1 table2 > mybackup_01082012_table2.sql

Restore database

Restore all the database from file.

  • user name: my_username (-uUSERNAME)
  • password: mypassword (-pPASSWORD)
  • database name: databaseName
  • restore file: mybackup.sql
mysql -umy_username -pmypassword databaseName < mybackup.sql
Navigation
Web
SQL
MISC
References