Give a website its own database
This page creates a website database on either engine, gets the connection details into an application’s configuration, brings an existing database across from another host, and sets a size limit. It also lists the limits you will meet and what each one does when you reach it.
Which database your server runs
MySQL or MariaDB, decided when the server is built.
MySQL is the default. Most people arrive with a database they already have and theirs is usually MySQL, and a dump MySQL wrote imports into MySQL without being edited first. Pass --database-engine mariadb at install to build the server on MariaDB instead.
The two cannot be installed side by side: each declares a conflict with the other and they want the same port and the same data directory. So this is chosen once, when the server is built. A server that already runs one keeps it and tells you so rather than replacing it, because switching means migrating every database on the machine and that is a job with a backup behind it.
Nearly everything in the panel is the same either way. Two differences are worth knowing:
- A dump written by MySQL 8 names a collation that older MariaDB does not have, so importing one into MariaDB fails until it is edited. On a MySQL server it simply imports.
- Moodle needs MySQL 8.4, and Ubuntu carries 8.0, so a server built on MySQL refuses to install Moodle and says why. A server built on MariaDB runs it. Every other application in the catalogue installs on either.
Step 1
Create the database.
Open the website, then the engine you want under Databases. A server is built on MySQL or on MariaDB, and the tab is headed with whichever yours has; PostgreSQL appears beside it when the server has that too. Only the engines your server has are listed. Then New database.
The only thing to decide is the name. That name is yours, for telling one database from another in the panel; the database server never sees it. The real database is called hpd_ followed by an internal identifier, and the panel shows you that name wherever you need it.
A database cannot move to the other engine afterwards, because the two do not read each other’s data. Pick PostgreSQL when the application asks for it; otherwise use the one your server was built on.
Then Create account, which is what your application signs in as. The account reaches that one database and nothing else, and its password is shown once and never stored, so copy it before closing the dialogue.
Step 2
Put the details in your application.
Four values, all shown when you create the account. Nothing on the internet can reach your database whatever the password: neither engine listens on a network address.
Use the host the panel gives you, not localhost. It is localhost for a PHP or Node website on MySQL or MariaDB, because those run on the server itself. It is a socket path for everything else, and inside a container localhost is the container rather than the server, so an application given it reports that the database is not running.
Host localhost PHP or Node, MySQL or MariaDB
/run/mysqld/mysqld.sock a container, MySQL or MariaDB
/var/run/postgresql PostgreSQL
Database hpd_4f2c8a1b9e0d7c36
Username hpu_8b3e1f0a7c92d546
Password shown once when you create the account
For WordPress that is wp-config.php:
define( 'DB_HOST', 'localhost' ); define( 'DB_NAME', 'hpd_4f2c8a1b9e0d7c36' ); define( 'DB_USER', 'hpu_8b3e1f0a7c92d546' ); define( 'DB_PASSWORD', 'the password you copied' );
For Laravel and anything else reading a .env file:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=hpd_4f2c8a1b9e0d7c36 DB_USERNAME=hpu_8b3e1f0a7c92d546 DB_PASSWORD=the password you copied
Put the file outside the folder the web server serves, or make sure the server will not hand it out. A .env inside public_html is readable by anybody who guesses its name.
If you would rather work in a familiar tool, phpMyAdmin opens from a MySQL or MariaDB database’s page, already signed in as that website’s own account. The link is good for a couple of minutes and once only, so open it from the panel each time rather than bookmarking it.
PostgreSQL
What is different on the second engine.
Creating a database, issuing accounts, size limits and backups all work the same way. Four things do not.
| Thing | On PostgreSQL |
|---|---|
| Connection string | The panel gives you one, ready to paste. The socket goes in the host part, percent encoded, because a path cannot sit there as it is. |
| Symfony and Laravel | Symfony reads a per cent sign in a setting as its own syntax, so the panel gives a second string with them doubled. Use that one for Symfony, or the application stops before it connects. |
| Importing a dump | Not available yet. Create the schema from the application, which is what most of them do on first start. |
| phpMyAdmin | A tool for the MySQL family, so it is not offered here. Use psql over SSH, or the application’s own tooling. |
Over its size limit, PostgreSQL refuses writes and keeps reads working, the same promise as the other engine by a different route: the website’s accounts are moved to a role that may only read. Deleting rows does not return the space on its own, and VACUUM FULL does.
Step 3
Bring an existing database across.
This is MySQL and MariaDB only for now. Export from the old server, create the database here, then Import SQL into it. Import runs your file as it stands, so what it does depends on what is in it. A dump from mysqldump or mariadb-dump normally carries a DROP TABLE IF EXISTS before each table, which means it replaces the tables it contains and leaves anything else in the database untouched. Importing into a database you have just made avoids having to think about it.
mysqldump -u olduser -p --single-transaction \ --default-character-set=utf8mb4 oldname > oldname.sql
A dump from phpMyAdmin or another panel works just as well. If yours is over the 64 MiB limit, the usual reason is a log or session table you do not need; drop it before dumping. If it is genuinely that large, moving the website over SSH has no such limit and brings the files too.
The fields
What each input means, and what it refuses.
| Field | What it is for | Limits and refusals |
|---|---|---|
| Name (database) | Your label for it, so you can tell shop from blog in the panel. It is not the name the database server uses. |
1 to 31 characters, lowercase letters, digits and underscore, starting with a letter or digit. Anything else is refused. Capitals are folded to lowercase. |
| Name (account) | Your label for the account, on the same rules. The real username is derived and begins hpu_. |
As above. |
| SQL file | A dump to import, plain or compressed. | 64 MiB. A larger file is refused before anything is read. |
| Size limit | How large this database may grow, its storage quota. Administrators only: a customer can see the quota but not change it. | 0 for no limit, otherwise between 1 MiB and 1 TiB. A limit below 1 MiB would be met by an empty database and suspend it the moment it was created. |
| Confirmation | Deleting a database, restoring over one, or changing an account password asks you to type the database name back. | It must match exactly. A restore overwrites the tables in the backup, so this is the only guard between a tired afternoon and yesterday’s data. |
Limits
What you can have, per website.
| Limit | Value | What happens at the limit |
|---|---|---|
| Databases per website | 20 | Creating the twenty-first is refused. The hosting package’s own allowance usually bites first: a plan with three databases allows three. |
| Accounts per database | 10 | Creating another is refused. One per application is the useful number; a second is handy for a read-only reporting tool. |
| Manual backups per database | 10 | Taking another is refused until you delete one. Recovery points for the whole website are counted separately. |
| Import size | 64 MiB | Refused. Use an SSH move instead. |
| Size limit range | 1 MiB to 1 TiB, or 0 | Outside that range the limit is refused rather than stored. |
Over the limit
What a database over its quota can still do.
A database over its size limit does not break and is not deleted. Its account keeps the privileges it needs to get back under the limit and loses the ones that would make things worse: it can still read, delete rows, drop tables, lock tables and run routines, but it cannot insert or update.
So an application will usually report that a write failed while its pages still load, and clearing out whatever grew will put it back. The quota is enforced by the database’s own grant rather than by the panel asking nicely, which is why it holds even for a script connecting directly.
The size shown is the database’s files on disk, measured by the server rather than read out of information_schema. Those statistics lag badly: a directory really holding 9.4 MB reported 16 KB before an ANALYZE and 1.6 MB after one. If a tool shows you a smaller number than the panel does, the panel is the one measuring the disk the limit protects.
Backups
A database on its own, or the whole website.
A database backup is this one thing and is quick both ways: Restore backup puts it back without touching the website’s files. That is what you want when the mistake was a bad query rather than a bad release.
A restore drops and recreates each table the backup holds. A table created after the backup was taken, and so not in it, survives the restore. If you want the database exactly as it was, delete it and restore into a fresh one.
A recovery point is the whole website, databases first and then files, so the database is never newer than the code expecting it. While a backup runs, the database is briefly held read-only so the copy is consistent; the window is bounded at an hour and normally lasts seconds. See backups and recovery points.
Copying a website gives the copy its own database rather than pointing it at the live one, so a staging site is a real staging site. Run a risky migration there first, against a database with the same shape and its own data.
Databases count against the hosting package’s allowance. See customers and hosting packages.
Your servers, with nothing on them counted.
The whole panel is free on one server, with no limit on websites, mailboxes, DNS zones or customer accounts. Pro carries five servers and Business as many as you run.