Command Line Backup


A simple and easy method for creating MySQL backups is to use the mysqldump command. This command will create a simple .sql file of an existing database, which can then be restored to any other empty MySQL database.

Syntax


[server]$ mysqldump --opt --user={username} -p={password} --host={hostname} {dbname} > {filename}.sql

The parameters of the said command as follows:

{username} - MySQL username.

{password} - MySQL password for the user. Use single quotes around the password

{dbname} - Database name you want to take backup.

{hostname} - Hostname your database resides on

{filename} - The name of backup dump file you want to generate.

Example


[server]$ mysqldump --opt --user=admin -p='12345678' --host=mysql.mydomain.com mydatabase > mybackupfile.sql

Cookies help us deliver our services. By using our services, you agree to our use of cookies.