Connect to Your CodeRed Database

CodeRed MariaDB or PostgreSQL databases are designed to be used directly by your website. However, they can be connected to externally using standard MariaDB/MySQL or PostgreSQL clients.

Step 1: Install a Client

This guide will use the official mysql client shipped with MariaDB and psql command shipped with PostgreSQL. If you do not have these installed, They can be installed from the following links, or from your system’s package manager. For best results, ensure the version installed is equal to or higher than the version of your CodeRed database.

During installation, the server component is not required, only the client tools.

Step 2: Obtain Your CodeRed Database Credentials

From the CodeRed Dashboard, select your website and then select the Database tab. This will provide the connection info. To retrieve the password, click the Show Production/Staging password button.

Note

For enhanced security, database passwords are automatically rotated every time your app is deployed. This password is therefore temporary and should never be stored or used in code.

Step 3: Connect to the Database via Command Line

The CodeRed Dashboard Database tab also provides a command line snippet which can be copy/pasted to connect directly to your database. Enter the password from Step 2 above when prompted.

$ mysql -h <host> -u <user> -p --ssl <database_name>
PS> mysql -h <host> -u <user> -p --ssl <database_name>

Note

On Windows, the mysql program may not be on your PATH. In that case, you can reference the full path (which is most likely located somewhere in your Program Files folder). For example: C:\Program Files\MariaDB 10.5\bin\mysql.exe

$ psql "host=<host> user=<user> dbname=<database_name> ssl=require"
PS> psql "host=<host> user=<user> dbname=<database_name> ssl=require"

Note

On Windows, the psql program may not be on your PATH. In that case, you can reference the full path (which is most likely located somewhere in your Program Files folder). For example: C:\Program Files\PostgreSQL\12\bin\psql.exe