How to duplicate a database in mysql/mariadb

When backup database, don’t use option –databases. It will create use database command.

mysqldump -u root -p oldDB > oldDB.sql
mysql -u root -p --execute="create database newDB;"
mysql -u root -p newDB < oldDB.sql

Leave a Reply

Your email address will not be published. Required fields are marked *