33

How do I import a database just like in phpmyadmin at DataGrip?

I have the .sql exported from phpmyadmin... but those are lots of lines so that the IDE stops working when trying to run the whole .sql

1
  • 1
    Were you able to find a quick way to do this in DataGrip?
    – Karl
    May 9, 2017 at 19:36

5 Answers 5

70

In DataGrip go to File > Open and select your mysql dump file. Then right click the tab for the file to get the context menu, and select "Run [your filename...]" option. It may ask you to select your schema to apply the run to. But this is how I accomplished importing a dump from phpMyadmin using DataGrip.

enter image description here

3
  • 8
    This is not intuitive. I just came here from scouring the UI for a solution, and I would have never considered right-clicking on an SQL file tab. Thanks.
    – asciimo
    Aug 29, 2018 at 21:09
  • The instructions were to right-click the database and "Restore with mysql"... which does absolutely nothing and outputs no error. Feb 5, 2020 at 15:39
  • 1
    This didn't work with .sql files for MariaDB sources, but works with MySQL. MariaDB sources aren't visible on import sources after the step of the screenshot. I had to right click to the database from the left sources list and click "Restore with 'mysql'" to restore my db dump.
    – Arda
    Feb 12, 2020 at 9:32
6

Jetbrains documentation on running SQL scripts does not provide a ton of information on processing large insert statements. There is a discussion in the Datagrip community forums and apparently upcoming features to make working with large scripts easier.

Quote from thread:

Huge SQL files can be executed from Files view (use a context menu action).

I assume you are attempting to import a database export which is a series of SQL statements saved to a file. There could be a memory issue if you are attempting to run a large SQL file in memory. Try the following.

Insert commit statements in your SQL file in a text editor. This can even be done from within datagrip. Every couple of hundred statements you can place the line

commit;

which should purge the previous statements from memory. I strongly recommend saving the file which you edit separately from the export script. This method is not applicable if you need an all or nothing import, meaning if even one statement or block fails you want all of the statement to be rolled back.

3

1 - Going to View->Tool Windows->Files enter image description here

2 - Going to schema folder and open it in windows explorer after that past your dump file in my example i will past MyDump.dmp .

enter image description here

3 - Right click on the MyDump.dmp and run it .

enter image description here

0

To import data from a script file, run the file as it is described in Run database code. In addition to script files, you can import a CSV, TSV, or any other text file that contains delimiter-separated values.

https://www.jetbrains.com/help/datagrip/import-data.html

0

I found this article helpful:

https://www.jetbrains.com/help/datagrip/import-data.html#import-data-to-a-database

Right-click on the schema name in Database Explorer and select SQL Scripts > Run SQL Script. Then select the file you want to import.

This worked well for me in DataGrip 2023.1.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.