# Create a MySQL data source using unix sockets

Procedure: Enable the Database Tools and SQL plugin

This functionality relies on the  Database Tools and SQL plugin, which  is bundled and enabled in IntelliJ IDEA   by default. If the relevant features are not available, make sure that you did not disable the plugin.

> **Note:**
> Database Tools and SQL functionality support is limited in IntelliJ IDEA without the Ultimate subscription.

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Plugins`.

2. Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.

On Unix, you can connect to the mysqld server by using two different ways: a Unix socket file (for example, `/var/run/mysqld/mysqld.sock`), or by using TCP/IP (for example, `127.0.0.1:3306`). A connection created with a Unix socket file is faster than TCP/IP but can only be used when connecting to a server on the same computer. When you use a Unix socket file, you can skip a hostname and port in the connection string.

## Prerequisites

* Linux only

* Junixsocket JAR files: [the junixsocket repository at github.com](https://github.com/kohlschutter/junixsocket/releases)

* IntelliJ IDEA must be on the host where the server is running ([MySQL 8.0 Reference Manual at dev.mysql.com](https://dev.mysql.com/doc/refman/8.0/en/can-not-connect-to-server.html))

## Step 1. Locate a Unix socket file

Procedure:

1. On the server host in the command line, run the following command:

```CONSOLE
mysql -u root -p -h 127.0.0.1 -e "select @@socket"
```

2. Type a password for your `root` user and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![Locate a Unix socket file](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_tutorial_unix_sockets_check_sockets.png)

## Step 2. Check the Unix socket connection from the command line

Procedure:

1. In the command line, run the following command: `mysql -u root -p -S /var/run/mysqld/mysql.sock`.

2. Type a password for your `root` user and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![Check the Unix socket connection from the command line](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_tutorial_unix_sockets_check_connection.png)

## Step 3. Download third-party libraries

The Connector/J driver does not natively support connections to MySQL Servers with Unix domain sockets. To enable socket connection, you need to download third-party libraries. For more information about this limitation, refer to [Connecting Using Unix Domain Sockets at dev.mysql.com](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-unix-socket.html).

Procedure:

1. Download the latest release from [the junixsocket repository at github.com](https://github.com/kohlschutter/junixsocket/releases) (for example, `junixsocket-dist-2.3.2-bin.tar.gz`).

2. Extract the downloaded archive. You need to add the following files from the `lib` directory to the MySQL driver in IntelliJ IDEA:

* `junixsocket-mysql-2.3.2.jar`

* `junixsocket-native-common-2.3.2.jar`, if you have a custom architecture try `junixsocket-native-custom-2.3.2.jar`

* `junixsocket-core-2.3.2.jar`

* `junixsocket-common-2.3.2.jar`

## Step 4. Configure the MySQL driver in IntelliJ IDEA

Procedure:

1. Open data source properties by doing one of the following:

* On the Database tool window toolbar, click ![The Data Sources icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/database-plugin.icons.expui.manageDataSources.svg) Data Sources.

* Press `Shift+Enter` (Windows), `⌘ I` (macOS), `⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ I` (macOS System Shortcuts), `Shift+Enter` (XWin), `Shift+Enter` (GNOME), `Shift+Enter` (KDE), `Shift+Enter` (Emacs), `Shift+Enter` (Sublime Text), `⌘ I` (Sublime Text (macOS)), `Shift+Enter` (NetBeans), `Shift+Enter` (Visual Studio), `⌘ I` (Visual Studio (macOS)), `Shift+Enter` (Eclipse), `⌘ I` (Eclipse (macOS)) .

![Open the Data Source and Drivers dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/open_data_sources_and_drivers_dialog.png)

2. In the Drivers section, click the MySQL driver and click the Duplicate button ![the Duplicate button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.copy.svg). Alternatively, press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Meta+D` (Emacs), `Ctrl+Shift+D` (Sublime Text), `⌘ ⇧ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `Ctrl+D` (Eclipse (macOS)).

3. Change the name of the duplicated driver (for example, MySQL socket).

4. On the General tab, click the Add button (![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg)) and select Custom JARs.

5. In the file browser, navigate to a folder with third-party libraries (refer to [Step 3](#step-3-download-third-party-libraries)). While pressing `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (NetBeans), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)), select the following files:

* `junixsocket-mysql-2.3.2.jar`

* `junixsocket-native-common-2.3.2.jar`, if you have a custom architecture try `junixsocket-native-custom-2.3.2.jar`

* `junixsocket-core-2.3.2.jar`

* `junixsocket-common-2.3.2.jar`

6. Click OK.

7. On the Advanced tab, find the socketFactory property, double-click the Value cell, and change the value to `org.newsclub.net.mysql.AFUNIXDatabaseSocketFactory`.

![Change the socketFactory property](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_tutorial_unix_sockets_socketfactory.png)

8. Scroll down to the end of the property list, double-click the <user defined> cell and type `junixsocket.file`. Double-click the Value cell and type the path to your socket file (refer to [Step 1](#step-1-locate-a-unix-socket-file)).

![Add the junixsocket.file property](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_tutorial_unix_sockets_junixsocket_file.png)

9. Click Apply.

## Step 5. Create a connection to the MySQL server

Procedure:

To connect to a database, create a data source that will store your connection details.

1. Select the data source you want to create. You can do this using one of the following ways:

* In the main menu, go to `File | New | Data Source` and select MySQL.

* In the Database tool window , click ![the New icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) New on the toolbar. Navigate to Data Source and select MySQL.

![Create a new data source](https://resources.jetbrains.com.cn/help/img/idea/2026.2/create_new_data_source.png)

2. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the [JetBrains JDBC drivers](https://www.jetbrains.com.cn/en-us/datagrip/jdbc-drivers/) page.

![The Download missing driver files link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_download_missing_drivers_link.png)

Location for the downloaded JDBC drivers is the [IntelliJ IDEA configuration directory](directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory).

You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, refer to [Add a user driver to an existing connection](jdbc-drivers.html#configure_a_jdbc_driver_for_an_existing_data_source).

If there is no Download missing driver files link, then you already have the required drivers.

3. On the Advanced tab, find the `serverTimezone` parameter in the list of options. Double-click the Value cell and type your server timezone (for example, `UTC`).

4. Click the General tab.

5. From the Driver list, select the driver that you created earlier (refer to [Step 4](#step-4-configure-the-mysql-driver-in-ide)).

6. In the User and Password fields, specify your user credentials.

7. Ensure that the database connection can be established using the provided details. To do this, click the Test Connection  link at the bottom of the connection details section.

![Test Connection link](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_test_connection_link.png)

If you encounter any connection issues, refer to the [Cannot connect to a database](connectivity-problems.html) page.

8. (Optional) By default, only the default    schema is   introspected and available to work with. If you also want to work with other     schemas  , in the Schemas tab, select them for the introspection.

![Schemas tab of the Data Sources and Drivers dialog](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_connection_schemas_tab.png)

9. Click OK to create the data source.

10. Find your new data source in the    Database   tool window   .

* For more information about the Database tool window , see the corresponding [reference topic](database-tool-window.html). > **Tip:** > To see more schemas under your new data source node, click the N of M button and select the ones you need. IntelliJ IDEA will introspect and show them. > > > > ![Select databases and schemas to introspect and display in the Database tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/connection_flow_show_databases_and_schemas.png)

* For more information about working with database objects in IntelliJ IDEA, refer to [Database objects](database-objects.html).

* To write and run queries, open the default [query console](query-consoles.html) by clicking the data source and pressing `F4` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS)).

* To view and edit data of a database object, open [Data editor and viewer](data-editor-and-viewer.html) by double-clicking the object.

## See also

### Reference

[Data sources and their elements](database-tool-window.html#icons-for-data-sources-and-their-elements) [Data Sources and Drivers dialog](data-sources-and-drivers-dialog.html)

### Tool Windows

[Database tool window](database-tool-window.html)

