One of the client are requesting to duplicate their database to development database in case their production database have change mistakenly.
Scenario:
– MySQL Database server
– Root password: [email protected]
– Production Database: db1
– Development Database: db2
– Development User: db_user
– Development User Password: [email protected]
To do this, I choose to use mysqldump to done it.
1. First of all, you must create the development database named db2.
mysql -u root -p'[email protected]' -e "create database db2"
2. Next, you may duplicate the database data from db1 to db2.
mysqldump -u root -p'[email protected]' db1 | mysql -u root -p'[email protected]' db2
3. Now, you need to assign the MySQL user permission to the db2(development) database.
a) Log into the database server.
mysql -u root -p'[email protected]'
b) Grant the database privilege,
mysql> GRANT ALL PRIVILEGES ON db2.* TO [email protected] ;