To rename a database in MySQL you need to follow the steps given below:
- Dump the schema using Mysqldump
- Restore the dump schema to other schema
- Drop the old schema(if required)
For Example:
Suppose we have a database emp which needed to renamed as employees. For this we will write the following MySQL statements using command line:
Step 1:Dump the emp by using following statement
mysqldump -u root -p emp > emp.sql
Step 2: Create new database employees
mysql -u root -p -e "create database employees"
Step 3:Restore the emp database to employees db
mysql -u root -p employees < emp.sql
Step 4:Drop the database emp
mysql -u root -p -e drop database emp
0 Comment(s)