Back up and Restore MySQL database for Wordpress
Whether you are switching your web host or changing a Wordpress theme, backing up your MySQL database regularly is always a good practise.
To back up Wordpress on localhost,
$ mysql -u username -p password -h localhost databasename > databasebackup.sql
To back up database at remote host, you need to make sure that you know ip address of the host, database username, password of your host database, ssh access. All these information should be provided by your host. If you can't find them, contact them directly. The command to back up database at remote host is,
$ mysql -u username -p password -h 123.123.456.456 databasename > databasebackup.sql
To restore your database using the backup file,
$ mysqldump -u username -p password databasename > databasebackup.sql
The above commands were tested on MySQL version:
Ver 14.14 Distrib 5.1.54, for debian-linux-gnu (i686)
References:
[1] Import MySQL dumpfile, SQL datafile into my database
[2] Backing Up and Restoring Your MySQL Database