There are three different solutions to access Scalingo’s databases:
- Remote console: an interactive console is started and you access it directly.
- Encrypted tunnel: if you want a full access to the database, you have to build an SSH-encrypted tunnel, then you will be able to access the database as if it was running locally. You have to use this solution if you want to import/export data.
- Direct encrypted access to the database.
Interactive Remote Console
The following commands let you open a console for the database of your choice. Note that your should have added the appropriate addon from your application dashboard prior to run one of these commands.
# Open a console using the `mysql` client scalingo --app my-app mysql-console # Open a console using the `psql` client scalingo --app my-app pgsql-console # Open a console using the `mongo` client scalingo --app my-app mongo-console # Open a console using the `redis-cli` client scalingo --app my-app redis-console
Manually install the databases CLI in one-off
If you started a Bash process in a one-off container, you can download various CLI tools for all databases available at Scalingo:
You can use the script
dbclient-fetcher to download and install it. Using this script is
as simple as:
[10:48] Scalingo ~ $ dbclient-fetcher mongo ---> Download and extract the database CLI ---> Database CLI installed: MongoDB shell version: 3.4.9
If you ever need a specific version, just add it as a second parameter:
[10:48] Scalingo ~ $ dbclient-fetcher mongo 3.2 ---> Download and extract the database CLI ---> Database CLI installed: MongoDB shell version: 3.2.17
Connect to the Database
By default, databases hosted on Scalingo are not directly available on the Internet.
To access your database remotely from your workstation you need to setup an encrypted connection: either via an encrypted tunnel or by forcing TLS connection to your database and enabling direct Internet access.
Since we don’t want unencrypted network traffic from/to your databases, the DB tunnel provides an encrypted way to access them. However, it does not provide any additional security layer. We will only verify that your public key is registered on our platform. The DB tunnel is an encrypted bridge between your laptop and our infrastructure.
Another possibility is to make your database accessible from internet.
Build the Tunnel
By running the following command, an encrypted SSH tunnel will be built between you and your database.
$ scalingo --app my-app db-tunnel MONGO_URL Building tunnel to <dbhost>:<dbport> You can access your database on '127.0.0.1:<localport>'
Use any client to read, import or export your data
Once the tunnel has been built, you can use any tool you need by connecting it to the
$ scalingo --app my-app db-tunnel MONGO_URL Building tunnel to <dbhost>:<dbport> You can access your database on '127.0.0.1:10000' # In another terminal $ scalingo --app my-app env | grep MONGO_URL MONGO_URL=mongo://user:secret@<dbhost>:<dbport>/database?options $ mongo "mongo://user:secret@<dbhost>:<dbport>/database?options" $ mongodump -u user -p secret -h localhost:10000 -d database
If you are connecting to the database using SSL/TLS, you should add both options
--sslAllowInvalidCertificates to the
Build the tunnel with the OpenSSH client
Our command line tool handles it in a single command, but you might want to use the tunnel without it. With the standard OpenSSH client, the way to build the tunnel is:
ssh -L <local port>:<database host>:<database port> git@<SSH hostname>:<SSH port> -N
The SSH hostname and port depend on the region of your application:
- 3DS Outscale Paris:
- SSH Hostname: ssh.osc-fr1.scalingo.com
- SSH Port: 22
- 3DS Outscale Paris SecNumCloud:
- SSH Hostname: ssh.osc-secnum-fr1.scalingo.com
- SSH Port: 22
The database host and database port can be found in the environment variable
representing the connection string of your database instance. Get it from the
dashboard or with the
env command of the CLI. It should look like:
The value of this variable is an URL which represents:
As stated previously, you need to get the
port from the URL.
If the app is in the region
osc-fr1 and if the environment variable is the following:
The command to run is:
ssh -L 10000:my-db.postgresql.dbs.appsdeck.eu:30000 firstname.lastname@example.org -N
Then you connect on
localhost:10000 to reach your Scalingo database. (You’ll still need to authenticate to the
database with the credential you can get from the connection string)
It is possible to make your database reachable from anywhere on the Internet. Head to your database dashboard. From there you first need to force TLS connections to your database. You can then toggle “Internet Accessibility” to make it reachable from the Internet.