AsapHogFtw
AsapHogFtw

Reputation: 321

Copying/Cloning database in Datagrip(MySQL)

How can I copy a schema to another schema I've created in Datagrip, essentially creating a clone of the original. For some reason my CMD prompt is not set for MySQL, and I have not found the way to do it via the Datagrip user interface.

Upvotes: 19

Views: 26834

Answers (2)

yyater97
yyater97

Reputation: 2933

  1. If you want to clone database structure only do this
  • Step 1: Choose the database which you want to clone.

  • Step 2: Right click => SQL Scripts => Generate DDL to Clipboard.

  • Step 3: Create a console file in destination DB => Paste DDL from the clipboard to it.

  • Step 4: Run all scripts.

enter image description here

  1. If you want to clone both structure and data do this
  • Step 1: From your destination data source create a new schema/database

enter image description here

  • Step 2: Drag and drop the current schema/database into the new schema/database which you just created

enter image description here

  • Step 3: modify something and press Import button to clone all of the tables

enter image description here

Upvotes: 12

moscas
moscas

Reputation: 10345

There can be two ways.

  1. Reliable and with data, but requires my_sqldump. Context menu of the schema -> Export with mysql_dump. After that, on your new schema go to Context menu -> Restore with mysql_dump.

enter image description here

  1. Works if your schema does not contain some very specific objects: LOGFILE GROUP, SERVER, SPATIAL REFERENCE SYSTEM, TABLESPACE. And with no data. Go to the context menu of the schema -> Sql Scripts -> SQL generator. There you will see the script to create the schema from scratch. Just run it on your new schema.

enter image description here

Upvotes: 7

Related Questions