Using the Database Client

Viewing data in the database is sometimes necessary to troubleshoot an issue with your application or for custom development. In order to access the database, you must use a built-in database client to interface directly with it. This feature is available in up-to-date versions of Liferay Cloud, and it can be accessed in a few short steps.

Note

Only Liferay Cloud users with Admin and Contributor privileges can make use of the database client.

You’ll use either the PostgreSQL client or MySQL client, depending on which database your environment uses.

PostgreSQL Client

Before you can use the PostgreSQL client via the Liferay service, you must upgrade your services to at least these supported image versions:

Prerequisites

ServiceMinimum Supported Image Version
Databaseliferaycloud/database:5.4.0
Liferay (7.4)liferaycloud/liferay-dxp:7.4-5.5.0
Liferay (7.3)liferaycloud/liferay-dxp:7.3-5.5.0
Liferay (7.2)liferaycloud/liferay-dxp:7.2-5.5.0
Liferay (7.1)liferaycloud/liferay-dxp:7.1-5.5.0

Accessing the PostgreSQL Client

  1. Log into the Liferay Cloud console.

  2. Navigate to the correct environment, and click Services:

    Navigate to Services to see all services for your environment.

  3. Click on the liferay service.

  4. Click the Shell tab.

  5. Type psql into the shell on this screen.

This logs you into the PostgreSQL client, where you can perform any read-only queries. For example, you can see all the tables by executing \dt.

Accessing the PostgreSQL client allows you to perform any read-only queries, such as printing all tables.

See the official PostgreSQL documentation for all the available commands.

Logging in with Read and Write Privileges

The default user can only perform read queries on the database, and cannot manipulate data. This prevents accidental modifications that may corrupt your services’ data.

However, if it is critical to manipulate data in the database, you can log in using your database credentials by typing this command into the shell (instead of only typing psql):

psql -U [LCP_SECRET_DATABASE_USER]

The client prompts you for the password. You can find the database name, user name, and password in your database service’s secrets.

Accessing the MySQL Client

  1. Log into the Liferay Cloud console.

  2. Navigate to the correct environment, and click Services:

  3. Click on the liferay service.

  4. Click the Shell tab.

  5. Type mysql into the shell on this screen.

This logs you into the MySQL client, where you can perform any read-only queries. For example, you can see all the tables by executing show tables;.

Run the mysql command and show tables command

See the official MySQL Client documentation for all the available commands.

Logging in with Read and Write Privileges

The default user can only perform read queries on the database, and cannot manipulate data. This prevents accidental modifications that may corrupt your services’ data.

However, if it is critical to manipulate data in the database, you can log in using your database credentials by typing this command into the shell (instead of only typing mysql):

mysql -u [LCP_SECRET_DATABASE_USER] -p

The client prompts you for the password. You can find the database name, user name, and password in your database service’s secrets.

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy