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.
Version | Hostname | Example command |
---|---|---|
MariaDB 10.11 | mariadb1011 | mysql -h mariadb1011 -u YOUR_DATABASE_USERNAME_HERE -p |
MySQL Server 8 | mysql8 | mysql -h mysql8 -u YOUR_DATABASE_USERNAME_HERE -p |
MySQL Server 5.7 | mysql57 | mysql -h mysql57 -u YOUR_DATABASE_USERNAME_HERE -p |
MySQL Server 5.6 | mysql56 | mysql -h mysql56 -u YOUR_DATABASE_USERNAME_HERE -p |
The behaviour of the mysql
command is the same for mysqladmin
and mysqldump
.
Database Dump Commands
Version | Dump command |
---|---|
MariaDB 10.11 | mariadbdump1011 |
MySQL Server 8 | mysqldump8 |
MySQL Server 5.7 | mysqldump57 |
MySQL Server 5.6 | mysqldump56 |
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:
WordPress Example
For example if you were setting up a WordPress install your wp-config.php
database section would look something like this:
PHPMyAdmin
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”.