Skip to main content

Access Database

danger

This guide is for advanced users only. Working directly with your database is a dangerous and unsupported workflow. If you are not comfortable working through the terminal, editing code, or overriding default options, please do not proceed. If you are unsure whether you require the functionality outlined in this guide, please reach out via the community forums. In order to get started with oc, elevated permissions must be requested by submitting a SNOW ticket to the IT Drupal Infrastructure Team here.

This guide assumes that you have a MySQL client (either CLI-based or graphical) installed on your machine. This guide further assumes that you are on the CERN network as outside connections are blocked by the CERN firewall. If you do not have oc available on your machine, please see this guide for more information.

  1. Connect to the Drupal cluster by executing the following command:

oc login --server=https://api.drupal.okd.cern.ch -u <username>

where username is your CERN usename.

  1. Extract the database connection information for your website by executing the following command:

oc -n PROJECT exec -c php-fpm deploy/MYSITE -- drush sql-connect

where PROJECT is your project and MYSITE is the specific website.

This gives an example output as follows:

mysql --user=0d4f580 --password=hSnc52hSN7C3 --database=0d4f580 --host=dbod-ha-proxy.cern.ch --port=7857 -A
  1. Use this information to connect to your database using your preferred database tool.

If, for instance, you are using DBeaver, you would

(a) Create a new connection

Creating a new connection.

Creating a new connection.

(b) Select MySQL

Selecting MySQL.

Selecting MySQL.

(c) Enter the values from step 2.

Entering connection settings.

Entering connection settings.

(d) Add SSH details to access when not on the CERN network.

Adding SSH information to access outside of CERN.

Adding SSH information to access outside of CERN.

(e) Select the database(s) of interest.

Selecting the database(s) of interest.

Selecting the database(s) of interest.