Connecting to a Database

RSS

Connecting to a Database

Last updated September 7th, 2018

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 username -p
MySQL Server 5.7 mysql57 mysql -h mysql57 -u username -p

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

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 navigate to CP » Cloud Containers » Databases, then click on the icon shown below to be taken to the login page:

PHPMyAdmin

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' );
Can we improve this article? Suggest an improvement to this article.

Suggest an Improvement

Thank you for helping us to improve this Knowledge Base article. Please type your suggestions below:

Still need help? Get in touch with us.

If you aren't able to find the help you need then please send us a question and we can help you further.