Skip to content

Connecting to a Database

Connecting to a MariaDB or MySQL database on Webslice Containers is similar to connecting 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 specific version of MariaDB or MySQL, for example: mariadb1011 or mysql57.

Database Versions

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

VersionHostnameExample command
MariaDB 10.11mariadb1011mysql -h mariadb1011 -u YOUR_DATABASE_USERNAME_HERE -p
MySQL Server 8mysql8mysql -h mysql8 -u YOUR_DATABASE_USERNAME_HERE -p
MySQL Server 5.7mysql57mysql -h mysql57 -u YOUR_DATABASE_USERNAME_HERE -p
MySQL Server 5.6mysql56mysql -h mysql56 -u YOUR_DATABASE_USERNAME_HERE -p

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

Database Dump Commands

VersionDump command
MariaDB 10.11mariadbdump1011
MySQL Server 8mysqldump8
MySQL Server 5.7mysqldump57
MySQL Server 5.6mysqldump56

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

You also need to add the name of the database, along with the credentials for an authorised user of the database.

For example:

mysqldump8 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', 'mysql8' );Copy


Want to manage your databases/tables via your web browser? Easy.

First, add a new container with the PHPMyAdmin Integrated Image. Staying in the Webslice Console, navigate to Containers > Databases and open the relevant Database Admin settings.

There’s more about this process in the Managing Databases doc, under “Viewing Database Data in Your Browser”.