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.
Asked
Active
Viewed 1.4k times
15
-
Database Tools → Copy Data Sources to Clipboard and then Import from Clipboard. images for that you find on the homepage https://www.jetbrains.com/de-de/datagrip/features/dbobjects.html search for Datenquellen kopieren – nbk Apr 29 '20 at 23:48
2 Answers
6
There can be two ways.
- 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.
- 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.

moscas
- 9,064
- 36
- 42
-
the first solution as some issue reported on datagrip, **sometimes mysqldump option disappear**, you have to check the URL in database properties. **Check jet-brains support page:** https://intellij-support.jetbrains.com/hc/en-us/community/posts/360006931279-mysqldump-is-missing-for-mysql-database – Mike D3ViD Tyson Dec 02 '20 at 15:24
5
- 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.
- If you want to clone both structure and data do this
- Step 1: From your destination data source create a new schema/database
- Step 2: Drag and drop the current schema/database into the new schema/database which you just created
- Step 3: modify something and press Import button to clone all of the tables

yyater97
- 1,697
- 2
- 9
- 5
-
I just tried "Option 2" to copy all tables and data and, while it creates all of the tables in the new schema, it only copies the data for the first table -- all the other tables are left empty. – walen Nov 30 '22 at 12:23