Dump a MySQL database and restore it in another database

Suppose you want to copy one MySQL production database to another MySQL database (in the same server) to have the production data in another environment (development or pre-production, for example).

The command you can use is this:

mysqldump -u user_db_production -ppass_db_production --routines --triggers db_production | mysql -u user_db_development -ppass_db_development -A -Ddb_development

First, the command makes a dump for the production database. With a pipe, the command restore the dump in the devolopment database.

Be careful sending emails in the development or pre-production environments.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.