I use MySQL on a daily basis. Most web developers connect to databases using GUI's such as phpmyadmin or MySQL query browser. This article will briefly explain how to use the command line to backup your databases, making it easy to automate your tasks using bash scripts.
Backing up a mysql database
mysqldump -u [uname] -p[pass] [dbname] > [backupfile.sql]
Restoring your MySQL database
mysql - u [uname] -p[pass] [dbname] < [backfile.sql]
More information
The above commands require a bit more explanation the square brackets represent a variable that you would enter yourself (don't put in the brackets).
Note there is no space between the -p option and the password. Usually when working on the command line we enter the password separately for security purposes.
Comments