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

前端 未结 30 2701
余生分开走
余生分开走 2020-11-22 14:54

The MySQL manual at MySQL covers this.

Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently

30条回答
  •  無奈伤痛
    2020-11-22 15:01

    Three options:

    1. Create the new database, bring down the server, move the files from one database folder to the other, and restart the server. Note that this will only work if ALL of your tables are MyISAM.

    2. Create the new database, use CREATE TABLE ... LIKE statements, and then use INSERT ... SELECT * FROM statements.

    3. Use mysqldump and reload with that file.

提交回复
热议问题