Dumping a Mysql Database


I’ve found that sometimes phpMyAdmin will time out will exporting or importing a database and just show a blank frame(the main frame). No thank you mam/sir. No thanks for playing, rather rude i must say. If you have access to a shell, thats ssh, you can dump a mysql file into the current directory my running the command below.

Database Dump

mysqldump -a -u username -p database > filename.mysql

this will result in a file called filename.mysql being created. You can go a step further and compress it. Because its a text file it’ll compress a hell of a lot. i once compressed a 3Gb db to about 800MB, i like to use gzip

gzip filename.mysql

And that will create a file called filename.mysql.gz

Database Import

importing a database is just as easy run the command below. Obvious if you had zipped in the step above you would need to uncompress it first uzip

gzip -d filename.mysql.gz
mysql -u username -p -h localhost data-base-name < filename.sql

About the author

Talifhani Luvhengo

A collection of particles named Tali Luvhengo

Add comment


Page optimized by WP Minify WordPress Plugin