MariaDB for hosts
This page is for system administrators and support staff at a hosting company who provide MariaDB databases for Exponential sites, which is the usual database a hosting panel creates. It answers: how MariaDB is driven, how to create a site's database and user, what to watch with character sets, and how to back it up. MariaDB is fourth in the official order and the MySQL-compatible server the project prefers. Sources: Database support and chapter 9.3.
Contents
- One driver for MariaDB and MySQL
- Versions
- Creating a database per site
- Settings and install
- Character sets
- Backups
- Problems and their causes
- Checklist
- Related pages
One driver for MariaDB and MySQL
MariaDB runs on the same driver as MySQL, eZMySQLiDB (lib/ezdb/classes/ezmysqlidb.php), on the PHP extension
mysqli. Everything on MySQL for hosts applies; this page covers what a host needs to do, and
what differs.
- The setup wizard lists it as "MySQL Improved".
exp:install --db=mariadbis the same as--db=mysql.- The kickstarter takes
[database_choice] Type=mysqli(mysqlaccepted). - MariaDB is not in the project's CI; the MySQL 8.0 job exercises the same driver, and MariaDB 10.5 runs on the project's development server (test coverage).
Versions
The wizard's floor is 4.1.1 (the MySQL number in eZSetupDatabaseMap()), which is not a recommendation. Run a
release your vendor still supports with security fixes, with utf8mb4 and InnoDB
(versions).
Creating a database per site
The installers do not create databases or users. No global privilege is needed:
CREATE DATABASE <customer> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER '<customer>'@'localhost' IDENTIFIED BY '<a strong password>';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
LOCK TABLES, CREATE TEMPORARY TABLES
ON <customer>.* TO '<customer>'@'localhost';LOCK TABLES and CREATE TEMPORARY TABLES are listed because the driver's lock() uses LOCK TABLES and the kernel
creates temporary tables for some operations. No SUPER and no right to list databases is needed.
Note
When a control panel creates the database, check its default character set and the privileges it grants against the statements above; check your panel's documentation for how to set them. The wizard refuses a database whose character set is not UTF-8 (Databases and users in control panels).
Settings and install
[DatabaseSettings]
DatabaseImplementation=ezmysqli
Server=localhost
# empty: 3306
Port=
User=<customer>
Password=<the password>
Database=<customer>
# a Unix socket instead of host and port
Socket=disabled
Charset=utf-8
UsePersistentConnection=disabledEXP_INSTALL_DB_PASSWORD='<the password>' php bin/php/console exp:install --apply --db=mariadb \
--db-host=127.0.0.1 --db-name=<customer> --db-user=<customer> --allow-root-userThe installer creates InnoDB tables when the server offers InnoDB; transactions need it. For an older installation,
php bin/php/ezconvertmysqltabletype.php --list lists the table types and --newtype=InnoDB converts them.
Read replicas. UseSlaveServer=enabled with SlaveServerArray[] and the related keys sends reads to a replica
chosen at random per request; writes go to Server. MySQL and MariaDB are the only engines with built-in read
splitting (chapter 9.3, Replicas).
Character sets
- Create the database in
utf8mb4. The installer creates its tables without a character set of their own, so they take the database's default. - The connection:
Charset=utf-8(the default) is sent to the server asutf8, which MariaDB treats as the three-byteutf8mb3. Characters outside the Basic Multilingual Plane, such as emoji, cannot pass through the connection even when the tables areutf8mb4. Keep the database inutf8mb4anyway. - If the connection character set cannot be set, the driver keeps running and logs "could not set the connection
charset", but only when warnings are logged (
site.ini [DebugSettings] AlwaysLog[]=warning). Text then comes back with?in place of characters.
The System information page warns when the connection's character set is not UTF-8.
Backups
mariadb-dump --single-transaction -u <customer> -p <customer> > <customer>.sql
mariadb -u <customer> -p <customer> < <customer>.sql--single-transaction gives a consistent dump of InnoDB tables without locking them; the older name mysqldump
works too. Commands with a password on the command line show it to other users of the machine; prefer the prompt or
an option file. A complete backup also contains var/storage, settings/override and settings/siteaccess.
Problems and their causes
| Symptom | Cause |
|---|---|
| The "database cannot be reached" page | wrong host, user, password or database |
| The wizard refuses the database's character set | the database was created in latin1 or another single-byte set; recreate it in utf8mb4 |
Text with ? where accented letters were | the connection fell back to the server's default character set |
| An extension's tables are not InnoDB | convert with ezconvertmysqltabletype.php --newtype=InnoDB |
| Slow pages | [DatabaseSettings] SQLOutput=enabled with QueryAnalysisOutput=enabled shows the analysis in the debug output |
Checklist
- To do: A supported MariaDB release with InnoDB.
- To do: One database per site in
utf8mb4, one user with the grants above. - To do:
mysqliin the web and the command line PHP. - To do: Panel defaults checked for character set and grants.
- To do:
mariadb-dump --single-transactionbackups scheduled and a restore tested.
Related pages
- Databases in the official order and MySQL for hosts
- Database support: MariaDB and character sets
- Chapter 9.3: MySQL and MariaDB
- Database backups per engine
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.