This is more to serve as a reminder for myself on how to backup and restore databases using the command line.
Where username is of course your username and dbname is the database that you are trying to backup. Userpass is optional - if you don't enter it on the command line, you will be prompted for it:
mysqldump -u username -p[userpass] dbname > filename.sql
or you can get fancier, if you need to specify the host or port:
mysqldump --user=username --password=password --port=port --host=hostname dbname > backupfile.sql
mysqldump -u username -p[userpass] dbname | gzip > filename.sql.gz
mysql -u username -p[root_password] database_name < filename.sql
mysqldump -u root -p[userpass] --all-databases > alldatabases.sql
Same as restoring a single one, except you don't specify a database:
mysql -u root -p[userpass] < alldatabases.sql