Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing databases between projects within Intellij

I use Intellij to inspect databases, run sql, view data in tables etc. This all works fine but the only thing I am missing is the ability to define these datasources once and view them in all my projects i.e. that I can share them between other projects and not have to redefine them for new projects. Is this possible in Intellij?

like image 399
Nos Avatar asked Jan 30 '17 11:01

Nos


People also ask

How does IntelliJ community connect to Database?

To add a new database connection (called a data source in IntelliJ), open the Database window View -> Tool Windows -> Databases, then click the + sign and select Data Source and then MySQL from the sub-menu. The defaults for the MySQL connection should for a local install of MySQL.

Can IntelliJ IDEA work with a specific database?

When you connect to a data source, IntelliJ IDEA can retrieve and display you all the databases that the data source has. But in some cases (for example, with certain settings of PgBouncer), you can or are allowed to work only with a certain database.

How do I Share my IntelliJ project on GitHub?

We can use IntelliJ IDEA to share this project on GitHub, we can go to the VCS menu and select Share project on GitHub. If we’re not already logged in to GitHub via IntelliJ IDEA, we’ll be shown a log in dialog where we can enter our GitHub username and password.

What is global data source in IntelliJ IDEA?

Data sources in IntelliJ IDEA are available at two levels: project and global. The project level means that you can access a data source only from the project where this data source was created initially. At the global level, a data source is available for other projects. By default, a data source is available at the project level.

How to share a data source between different projects in IDE?

By default, a data source is available at the project level. To share a data source between different projects inside your IDE, you need to move the data source to the global level.


1 Answers

Go to the Database tool window and click on the Data Source Properties button. Select the data source you want to make global. Click on the Make Global button in the tool bar above.

The Make Global button looks like this:

Make global button

Now you can use the data source from all your projects. However a global data source is not stored in the project files, so any other developers working on the same project will need to define their own data source.

like image 146
Bas Leijdekkers Avatar answered Sep 28 '22 09:09

Bas Leijdekkers