MySQL 迁移数据库 - zLulus/My_Note GitHub Wiki

思路:创建新数据库,将表逐个搬运到新数据库,再删除旧数据库

create database new_database;
rename table old_database.old_table to new_database.old_table;

为了更方便的找到所有表,写了以下sql

create database new_database;
SELECT CONCAT('rename table old_database.', table_name, '  to new_database.',table_name,';')
FROM information_schema.tables
WHERE table_schema='old_database'
order by table_name;