13 ส.ค. 2553

Backing & Restoring Mysql Database via the command line

Backing up via the command line
To backup from the command line of your shell account, log in and type the following at the prompt replacing USERNAME and DATABASE as described previously:

mysqldump -a -u USERNAME -p DATABASE > FILENAME.mysql

You will be prompted for your database password and then the DATABASE will be dumped to a plain-text file called FILENAME.mysql.

The resulting file, FILENAME.mysql, is a full backup with which you can fully restore your database in case of problems.

Restoring via the command line
Restoring from FILENAME.mysql is a three step process:

1.Drop the database
mysqladmin -u USERNAME -p drop DATABASE

2.Recreate the database
mysqladmin -u USERNAME -p create DATABASE

3.Import the backup data
mysql -u USERNAME -p Databasename < FILENAME.mysql

ไม่มีความคิดเห็น:

แสดงความคิดเห็น