MySQL Database Backup using mysqldump command.
If you have shell or telnet access to your web server, you can backup your MySQL data by using the mysqldump command. This command connects to the MySQL server and creates an SQL dump file. The dump file contains the SQL statements necessary to re-create the database. Here is the proper syntax::
~# mysqldump –opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
- [uname] Your database username
- [pass] The password for your database (note there is no space between -p and the password)
- [dbname] The name of your database
- [backupfile.sql] The filename for your database backup
- [–opt] The mysqldump option
For example, to backup a database named ‘IT-Tutorials-Online’ with the username ‘root’ and with no password to a file itto_backup.sql, you should accomplish this command::
~# mysqldump -u root -p IT-Tutorials-Online > itto_backup.sql
This command will backup the ”IT-Tutorials-Online” database into a file called itto_oackup.sql which will contain all the SQL statements needed to restore the database.
If you want to back up all the databases in the server at one time you should use the –all-databases option. It tells MySQL to dump all the databases it has in storage.
Content credit: mp3skull