mysql 5.7

Rename database in MySQL

rename database phpymadmin
rename database phpymadmin

From phpMyAdmin, select the database you want to select. In the tabs there’s one called Operations, go to the rename section. That’s all.

It does, as many suggested, create a new database with the new name, dump all tables of the old database into the new database and drop the old database.

Other method:

  1. Create a new database
  2. Create the rename queries with:
    SELECT CONCAT('RENAME TABLE ',table_schema,'.',table_name,
        ' TO ','new_schema.',table_name,';')
    FROM information_schema.TABLES
    WHERE table_schema LIKE 'old_schema';
  3. Run that output
  4. Delete old database

Leave a Reply