How to rename a mysql database name

Mysql workbench does not provide a way to easily rename a database.

However,you could use those commands in the terminal

mysqldump -u username -p -v olddatabase > olddbdump.sql mysqladmin -u username -p create newdatabase mysql -u username -p newdatabase < olddbdump.sql

Or

SELECT concat('RENAME TABLE $1.',table_name, ' TO $2.',table_name, ';')
FROM information_schema.TABLES 
WHERE table_schema='$1';

($1 and $2 are source and target respectively)

 

You must be logged in to post a comment.