Connect to Your CodeRed Database#
CodeRed databases are designed to be used directly by your website. However, they can be connected to externally using standard MySQL/MariaDB or PostgreSQL clients.
Step 1: Install a Client#
This guide will use the official mysql
client shipped with MySQL 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.
PostgreSQL: https://www.postgresql.org/download/
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.
All database connections require SSL (TLS). Modern versions of MySQL and
PostgreSQL clients attempt to connect over SSL by default, however older
versions or other tools may require an --ssl-mode
or sslmode
flag.
$ mysql -h <host> -u <user> -p <database_name>
PS> mysql -h <host> -u <user> -p <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\MySQL\MySQL Server 8.0\bin\mysql.exe
$ psql "host=<host> user=<user> dbname=<database_name>"
PS> psql "host=<host> user=<user> dbname=<database_name>"
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\15\bin\psql.exe