Sunday, April 7, 2013

Backup - Restore MySQL databases easily

,
As an IT there should be enough computers running MySQL which you would like to take care or maybe advantage easier than just looking around the fs without idea...
Let's say you hack into a system and all you do is their database! Hah, i am kiding, though, we would like to backup this database for security reasons.... How's the fast way? or How can we do this in a script?


Below are some commands that may be handy from time to time for those who doesn't already know..


Backup MySQL Database
# mysqldump -u(username) –p(password) (databasename) > (dumpfile.sql)

Backup all MySQL Databases
# mysqldump -u(username) –p(password) --all-databases > (dumpfile.sql)

Backup a Remote MySQL Database
 # mysqldump -h(hostip) -u(username) –p(password) (databasename) > (dumpfile.sql)

Restore MySQL Database
# mysql -u(username) –p(password) (databasename) < (dumpfile.sql)

Restore a database that already exist on the target machine
# mysqlimport -u(username) –p(password) (databasename) < (dumpfile.sql)

0 people replied to “Backup - Restore MySQL databases easily”

Post a Comment