Anybody know how to create new database in DataGrip (database IDE from JetBrains)? Could not find in DataGrip Help page.
5 Answers
In DataGrip 2017.1 UI for this was introduced

- 9,064
- 36
- 42
-
9This option doesn't seem to be showing up for mysql databases, but shows up for sql server. – Shahzad May 11 '17 at 11:20
-
4MySQL supports only one database per instance, right? You can create schemas in MySQL. – moscas May 12 '17 at 07:11
You first define the database. File --> Data Sources and Drivers --> Click on the green '+' in the top left corner to select the database type. And then fill in all the settings in the 'General' tab.
For example for PostgreSQL:
Host: localhost
Database: postgres
User: postgres
Password: password
Once you are set up, Ctrl+Shift+F10 to open the console and you can type your SQL statements, e.g.:
CREATE DATABASE my_database TEMPLATE template1

- 2,409
- 1
- 28
- 28
-
1When I posted this question, there wasn't possibility to create database from DataGrip UI. Anyway, thanks for answer. May be somebody needs it. – Abduhafiz Jun 01 '16 at 11:02
-
2This answer is not relevant, it is about creating a datasource, not database – moscas Mar 31 '17 at 11:25
I don't believe the existing answers cover MySQL... In MySQL, creating a new schema is equivalent to creating a new database. For this case, contextual-click (usually right-click) on your connection in the navigation tree and choose New | Schema. Give it a name and 'Execute in database".
The name of this schema will show up in the navigation tree and you can then add tables, data, etc.

- 240
- 2
- 9
The tricky part of creating a new database, is that you have to do it using a DataGrip "Data Source" where are are connected as a user that has the priviledge to create a database, which is generally the "admin" user that you added when you first installed Postgres which is connected to the main "postgres" database.
I like to keep track of all the commands I have run by attaching a new directory (File Menu | Attach Directory) and creating new files with descriptive names, such as "create_my_test_db.sql" and enter the sql to create the database:
create database my_test_db;
When you want to execute this code, make sure that you are using the correct "console". DataGrip has a drop-down menu in the upper-right corner above your file menu, so make sure you have selected "postgres@localhost", since this is the user Data Source that has privileges to create a new database.
Similarly, to create a new user for this data base, create a new sql file "create_my_test_db_user.sql"
create user my_test_db_user with encrypted password 'keyboard_cat';
grant all privileges on my_test_db to my_test_db_user;
Then you can create a new Data Source, and set the properties to host = localhost, user = my_test_db_user, and password = keyboard_cat.

- 1,429
- 14
- 16
Go to the name of your connection (eg: cat-app@localhost) ,right-click and select Schema. Creating a Schema and Database are same in Mysql.