DataGrip is an integrated development environment (IDE) developed by JetBrains for database management and SQL development. It can help database developers and data analysts to efficiently manage and query databases, write complex SQL queries, as well as design and maintain databases. This topic takes a MySQL tenant of OceanBase Database and the macOS operating system as an example to describe how to connect to OceanBase Database in DataGrip.
Prerequisites
You have downloaded and installed DataGrip. For more information, see the DataGrip official website.
The IP address of the OBServer node to be connected has access to the server where DataGrip is installed.
You have installed OceanBase Database and created a MySQL tenant.
Procedure
Step 1: Obtain the OceanBase Database connection string
Contact the deployment personnel or administrator of OceanBase Database to obtain the connection string. The following is a connection string example:
obclient -h$host -P$port -u$user_name -p$password -D$database_name
The parameters are described as follows:
$host: the IP address for connecting to OceanBase Database. It is the IP address of OceanBase Database Proxy (ODP) for connection through ODP, or the IP address of an OBServer node for direct connection.$port: the port for connecting to OceanBase Database. For connection through ODP, the default value is2883, which can be customized when ODP is deployed. For direct connection, the default value is2881, which can be customized when OceanBase Database is deployed.$database_name: the name of the database to be accessed.Notice
The user for connecting to a tenant must have the
CREATE,INSERT,DROP, andSELECTprivileges on the database. For more information about user privileges, see Privilege types in MySQL mode.$user_name: the tenant account. For connection through ODP, two account formats are supported:username@tenant name#cluster nameandcluster name:tenant name:username. For direct connection, theusername@tenant nameformat is supported.$password: the password of the account.
For more information about the connection string, see Connect to an OceanBase Database tenant by using OBClient.
Here is an example:
obclient -hxxx.xxx.xxx.xxx -P2881 -utest_user001@mysql001 -p****** -Dtest
Step 2: Create an OceanBase data source in DataGrip
If you use DataGrip for the first time, start DataGrip and click New Project to create a project.
In the new project, click the
icon on the top to open the control panel of Database Explorer.In the upper-left corner of Database Explorer, click the plus sign (+) and choose Data Source > MySQL > MySQL.
In the Data Sources dialog box, specify the following parameters based on the connection string obtained in Step 1.
Parameter Description Name The name of the custom data source. Host The IP address for connecting to OceanBase Database. The value is sourced from the -hparameter in the connection string.User The username of the account for connecting to OceanBase Database, for example, test. The value is sourced from the-uparameter in the connection string.Password The password of the account. The value is sourced from the -pparameter in the connection string.Port The port number for connecting to OceanBase Database. The value is sourced from the -Pparameter in the connection string.Database The name of the database to be accessed. The value is sourced from the -Dparameter in the connection string.Click Test Connection.
If a connection success message is displayed, click OK.
What to do next
DataGrip will be ready for use after the connection is created. For more information about how to use DataGrip, see DataGrip documentation.