Connecting to a Database

You can connect to a 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.

MySQL Versions

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

The table below describes how to do this:

MySQL Version MySQL 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

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

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' );

PHPMyAdmin

Every Cloud Container server comes with PHPMyAdmin. This will allow you to manage your databases/tables via your web browser. To find the PHPMyAdmin link follow the steps outlined in this article.