Published on
What you need a database for
Static sites made of pure HTML files get by without a database. As soon as content is managed dynamically - with WordPress, Joomla, a shop or a forum - texts, settings and user accounts live in a database, while only the program code and images are stored on the web hosting.
The database system used on the web hosting is MariaDB - the widely used, MySQL-compatible successor. Applications that require MySQL run on it unchanged; credentials and tools are the same too. We currently use the LTS series MariaDB 10.11.
The interplay of files and database has an important consequence for backups: a copy of the files alone is not a complete backup. Without the matching database state, all content is missing. More on this in the guide Create and restore backups.
Create a database in Plesk
- In Plesk, open the Databases section and click Add Database.
- Give it a name. Descriptive names help later - such as
wp_mainsiteinstead ofdb1. - Select the associated domain so that the assignment stays traceable.
- In the same dialog, create a database user and set a long, random password.
- Save and note the four values: database name, user name, password and host.
As the host, localhost usually goes into your application's configuration, because web server and database run on the same system.
One user per database
It is tempting to use a single database user for all projects. Do not do it. If one application is compromised, the attacker would otherwise have access to all databases on the web hosting - including the user accounts and order data of all other projects.
So create a separate user with its own password for each database. The extra effort is a few seconds per installation.
Enter the credentials in the application
After creating it, you enter the credentials in your application's configuration:
- WordPress: in
wp-config.php, the constantsDB_NAME,DB_USER,DB_PASSWORDandDB_HOST. - Joomla: the corresponding fields in
configuration.php. - Your own applications: in the respective configuration file or via environment variables.
If you install WordPress via the WordPress Toolkit, this step disappears - database, user and configuration are generated automatically. See Install WordPress.
Manage with phpMyAdmin
From the database overview in Plesk, one click takes you to phpMyAdmin - a graphical interface with which you can view tables, change values and run SQL queries. Typical tasks:
- Export: via the Export tab, you create a complete SQL dump as a file - the default settings are suitable for backups and moves.
- Import: via Import, you load a dump into an empty database.
- Search and replace: after a domain change or an SSL switch, old addresses can be replaced via SQL query.
- Clean up: old revisions, orphaned metadata and spam comments noticeably bloat WordPress databases over the years.
Before every direct intervention in the database, without exception: export first, then change. A faulty UPDATE cannot be undone.
Import large dumps
Importing via phpMyAdmin is tied to PHP's maximum upload size. Depending on the plan, it is 10 to 100 MB - larger dumps abort.
Two ways out: raise the values for upload size and maximum execution time in the domain's PHP settings (see Change the PHP version and settings), or split the dump into several files when exporting. With very large databases, support can help you.
Typical error messages
- "Error establishing a database connection": a value in the configuration is wrong. Check database name, user and password - and that
localhostis entered as the host. - "Access denied for user": the user exists but has no rights to this database. Check the assignment in Plesk.
- Import aborts without a message: file too large or time limit reached - see the section above.
- Garbled characters after the import: a different character encoding was used for export than for import. Use
utf8mb4in both steps.
If you move a site from another provider, the database is part of the process described in Migrate a website.
Frequently asked questions
Databases depending on the plan
Plan S includes 5 databases, plan XL 40. Every CMS installation takes up exactly one - that determines how many projects fit on one web hosting plan.
View web hosting plans & pricesRent web hosting
from €1.99 / month
Prepaid without a contract, Plesk included, hosted in Frankfurt am Main.
View plans & pricesRead more
- Web hosting - plans & prices
- Install WordPress
- Migrate a website
- Create & restore backups
- Change the PHP version
- Set up a cron job
Discover more