Connecting to a Database

You can connect to a MariaDB or MySQL database on Cloud Containers in much the same way you would connect in any other environment, with one key difference. The standard hostname of localhost will not work, instead you need to use the hostname for the version of mysql the database is using, eg: mysql57 or mariadb1011.

Database Versions

When using MySQL or MariaDB commands via the shell the hostname parameter must be supplied to make sure you are targeting the correct version.

The table below describes how to do this:

Version Hostname Example Command
MySQL Server 5.6 mysql56 mysql -h mysql56 -u YOUR_DATABASE_USERNAME_HERE -p
MySQL Server 5.7 mysql57 mysql -h mysql57 -u YOUR_DATABASE_USERNAME_HERE -p
MySQL Server 8 mysql8 mysql -h mysql8 -u YOUR_DATABASE_USERNAME_HERE -p
MariaDB 10.11 mariadb1011 mysql -h mariadb1011 -u YOUR_DATABASE_USERNAME_HERE -p

The behaviour of the mysql command is the same for mysqladmin and mysqldump.

Database Dumps

To get dump a specific version of a a MySQL database we recommend using the following commands:

MySQL Version MySQL Dump Command
MySQL Server 5.6 mysqldump56
MySQL Server 5.7 mysqldump57
MySQL Server 8 mysqldump8
MariaDB 10.11 mariadbdump1011

These will dump the specific database instance by resolving the version number to hostname with the corresponding name.

You will also need to add the name of the database you want to get a dump of along with the credentials for an authorised user of the database.

For example:

mysqldump57 YOUR_DATABASE_NAME -u YOUR_DATABASE_USER -p > dump.sql

WordPress Example

For example if you were setting up a WordPress install your wp-config.php database section would look something like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'mysql57' );


If you are looking to manage your databases/tables via your web browser, you might be interested in adding a PHPMyAdmin Cloud Container to your server. You can add PHPMyAdmin to your Cloud Container server by creating a new container with the PHPMyAdmin Integrated Image. To find the PHPMyAdmin link follow the steps outlined in this article.