Taking Database dump in Postgres and Mysql

Postgres

Database dump in postgres

$pg_dump93 -h /run/postgresql/9.3/ <database name> | gzip > /var/lib/postgresql/<database name>_$(date +%F).sql.gz

$pg_dump93 <database name> | gzip – > /var/tmp/filename.gz

$ pg_dump92 -h /run/postgresql/9.2/ -Fc -Z6 <database name> | gzip > /var/tmp/dbSas.dump$(date +$Y-%m-%d).sql.gz

psql93 -U cmdcoin cmdcoin <  /var/tmp/co_in_sql.sql

 Mysql

$ mysqldump <database name> | gzip > blogs_dump_2015-02-04.sql.gz

Import from sql file to database in Mysql

$ mysql databasename < /var/tmp/kbarticles.sql

Advertisements