How do I quickly rename a MySQL database (change schema name) - MySQL DBA Tutorial

How do I quickly rename a MySQL database (change schema name)

How to rename a database in MySQL is detail demo that explains how you can rename Database Name or Schema Name in MySQL Server. MySQL workbench does not really provide a straight forward way to Rename the Database/ Schema name in MySQL Server. 

To rename Database or Schema in MySQL server, first of all you need to create a new database/ Schema that you can do by using below command

Create database/schema SchemaName


Once you have the database ready, now you can move the tables from old database to new database by using blow statement.
Rename Table oldDBName.TableName to NewDatabaseName.TableName

Repeate above for all the tables in database, Then you can remove the old database by using below statement
Drop database/Schema DatabaseName


MySQL Workbench Tutorial - How to Rename Database / Schema in MySQL 



1 comment: