While taking backup of MySQL, one thing you need to understand that MySQL database are not backed up like ordinary files and folders. Even if it is possible, it would not be a standard solution, because it can corrupt the database file by doing so.
To back up your mysql database use ssh from your account, then use mysqldump commands :
Quote:
|
mysqldump -ppassword database name > db1.sql (db1.sql is your backup dump file, you can use any namefor your dump file)
|
That backs up the entire database in standard sql text format. Both the structure (like CREATE table command) and data (like INSERT command) statements, can be backed up individually, which is useful in many cases.
Quote:
|
To restore the dump file, just type: mysql -p dbname < db1.sql
|
Take a note : That the structure of dump file will not work if tables already exist. The backup will not change or replace the structure. For the data dump it will add any new data if it doesn't exist already.
To transfer a mysql database, create the dump file as mentioned above, use FTP to upload it on the another server, and then restore it as above. Mostly people think that database backup can be done via FTP as well. But it is not correct, at first you want to generate mysql dump, and then need to download that dump file.
You can use following mysqldump command lines:
Quote:
|
mysqldump -ppassword username > db1.sql
|
Use the next command to view the dump file:
Quote:
view db1.sql
(exit with: q!)
|
To place the file back: upload the file.
You can edit it with the help of a text editor. Include the following line at the top and use the database name, which is similar to your user name. Next >> save the file and fire the command:
mysql -ppasswd < db1.sql (All the database will be generated, including structure as well)