Databases and optimizer
This page explains how MoorCP stores account databases (MariaDB and PostgreSQL), how to move them to a separate database server, and the tools that keep databases fast. It is written for admins and technicians.
Open Servers › (server) › Settings › Databases.
Database engines
| Engine | Availability | Web manager |
|---|---|---|
| MariaDB | Installed on every hosting server. | phpMyAdmin |
| PostgreSQL 16 | Optional per server. | AdminNeo |
Database and user names always start with <account>_, for example jane_shop. The package's database quota counts MariaDB and PostgreSQL together.
Setting up PostgreSQL
PostgreSQL is set up per server, in one of these ways:
- when adding the server, add the
--pgsqloption to the agent installer command; - on a running server, call the API
POST /v1/servers/{id}/pgsql/setup.
The setup installs PostgreSQL 16 with SCRAM authentication and postgresql-contrib (extensions such as pgcrypto, uuid-ossp, pg_trgm, hstore, citext, and unaccent), revokes public access to other databases, and installs the PHP pgsql extension for every PHP version. The server's websites are then applied again so PHP loads pgsql and pdo_pgsql.
The setup is safe to repeat. An existing PostgreSQL cluster keeps its authentication settings. On servers set up before postgresql-contrib was added, run the setup again to install it.
PostgreSQL from cPanel
Importing a cPanel account (migration wave or cPanel archive restore) also imports its PostgreSQL databases, users, and grants. The target server must have PostgreSQL set up first; otherwise only that step fails and the rest of the import continues. PostgreSQL databases count toward the package's database quota in the pre-migration check. Extensions outside postgresql-contrib, such as PostGIS, must be installed by the admin first. See Importing from cPanel.
phpMyAdmin and AdminNeo
Both are installed from Settings › Apps & tools with the Install / update button. The server's hostname certificate must already be issued.
| Tool | Address | Extra requirement |
|---|---|---|
| phpMyAdmin | https://srv1.example.com/pma/ | - |
| AdminNeo | https://srv1.example.com/adminneo/ | PostgreSQL is set up. |
Clients and staff open them with a one-time link from the panel or billing, without a login form. AdminNeo uses a temporary role that can only open that account's databases, with a session of at most 4 hours.
Local database or external endpoint
Each hosting server has a database profile for MariaDB and one for PostgreSQL. Account databases can live in:
- Local: on the hosting server itself. This is the default.
- External endpoint: another database server, a VPS, or a managed service, reached over a private or public IP.
An external endpoint separates database load and storage from the web server.
Setting up an external endpoint
- On the engine card (MariaDB or PostgreSQL), click Configure.
- Choose External endpoint.
- Fill in the address:
- Private address: for one data center or VPC. Faster and not exposed to the internet;
- Public address: used when the private address is empty or the public network is chosen.
- Choose Connect through: Private network (recommended) or Public network.
- Fill in the port, Admin user, and Admin password. The password is stored encrypted in the panel. Leave it empty to use the stored password.
- Choose the TLS mode. For Verify, paste the CA certificate (PEM).
- If accounts already have databases, tick Move existing account databases and users to the new location.
- Click Test connection.
- If it succeeds, click Save and apply.
Privileges the admin user needs:
| Engine | Privileges |
|---|---|
| MariaDB | ALL PRIVILEGES ON *.* ... WITH GRANT OPTION |
| PostgreSQL | SUPERUSER, or CREATEROLE + CREATEDB on managed services |
TLS modes
| Mode | Behavior |
|---|---|
| Preferred | Encrypts when the database server offers it. |
| Required | Always encrypted, certificate not verified. |
| Verify | Encrypted, certificate checked against the CA you provide. |
| Disabled | No encryption. Only for private networks. |
WARNING
Database traffic over the public internet without TLS can be read by others. Use TLS or a private network.
Connection test
Test connection checks from the hosting server itself:
- the network path to the endpoint;
- TLS;
- admin privileges, by creating and dropping a test database and user;
- the hosting server's address as the database server sees it (This server as seen by the DB).
Allow address number 4 in the database server's firewall. Nothing is saved during the connection test.
Moving existing databases
The endpoint cannot be changed while accounts still have databases in the old location, unless the move option is ticked. If only the address or credentials change for the same database server, nothing is moved.
With the move option, the agent:
- copies every account database to the new endpoint;
- recreates users with their password hashes and privileges, so old passwords keep working;
- locks the users in the old location, so applications do not quietly keep writing to the old copy;
- changes
DB_HOSTin WordPresswp-config.phpfiles that still point tolocalhostto the new host; - reports the databases, users, and files changed.
The result is shown in the window, for example "2 database(s) and 3 user(s) copied". Click Run in background if you do not want to wait.
Applications other than WordPress
Other applications that store the database host in their configuration must be repointed manually. The host in use is shown on the client's Databases page.
Old data is not deleted
Data in the old location stays until you delete it yourself. If the move fails, nothing is moved and the server keeps using the old location.
When databases are moved from a managed PostgreSQL service with a non-superuser admin, password hashes cannot be read. Users are created with random passwords and the report asks for the passwords to be reset from the panel.
To go back to local, choose Local in the same window.
What adjusts along with it
- The client's Databases page shows the endpoint's host and port.
- phpMyAdmin and AdminNeo are still opened from the hosting server, then connect to the endpoint.
- One-click WordPress and Softaculous use the endpoint host.
- Backup, restore, moving accounts between servers, export, and import run over the endpoint connection.
Limitations:
- MySQL Governor only applies to local MariaDB.
- The slow query log of an external endpoint cannot be read from the hosting server.
Remote database access
Clients can let applications or tools on other computers connect to their MariaDB databases, like Remote MySQL in cPanel.
Allowing it
Remote access works when both are true:
- the account's package has the Remote database feature. See Packages;
- the Remote database access control on the account is not turned off. It is on by default. Turn it off in Accounts › (account) › Access controls to block one account. See Accounts.
The client then adds allowed hosts in Databases › Remote database access in the client panel, at most 20 per account:
| Entry | Example |
|---|---|
| IPv4 address | 203.0.113.7 |
| CIDR, /8 to /32 | 203.0.113.0/24 |
| Netmask | 203.0.113.0/255.255.255.0 |
| Wildcard octet | 203.0.113.% |
| Any address | %. The client panel asks for confirmation. |
IPv6 hosts are not supported for remote MariaDB yet.
What happens on the server
- Every database user of the account is copied to each allowed host with the same password, connection limit, lock state, and privileges (all or read-only). Custom privileges are not copied. The copies stay in sync when users, passwords, or privileges change, and the client panel only shows the original users.
- When firewalld runs, port 3306/tcp is opened only for the hosts of all accounts on the server, without a firewalld reload. Host
%opens 3306 to everyone. Rules an admin added earlier are never removed. - When firewalld is not running, the port is not filtered, and only the MariaDB user hosts limit access. When firewalld is turned on from the panel, the rules are added again.
- When the package or access control no longer allows remote access, the copies and firewall rules are removed. The client's host list stays saved and applies again once access is allowed.
The client panel shows a warning when MariaDB on the server does not accept network connections (skip_networking, or bind_address set to loopback). Change bind_address in the my.cnf editor if needed.
External endpoint
For accounts on an external endpoint, the connection address is the endpoint's public host. Open port 3306 on the database server itself. The hosting server's firewall is not used.
MariaDB tuning
The MariaDB tuning card gives recommendations from live server statistics, similar to MySQLTuner. The card shows the version, uptime, and server RAM.
What it checks: the InnoDB buffer pool and hit rate, peak connections, per-user connection limits, on-disk temporary tables, table cache, thread cache, query cache, slow query log, and failed connections. The RAM calculation leaves room for web and PHP on the same server.
Each recommendation has a level:
| Level | Meaning | Ticked automatically |
|---|---|---|
| Important | Can cause refused connections or memory pressure. | Yes |
| Recommended | Should be applied. | Yes |
| Tip | Optional. | No |
| information | Information only, with no value to apply. | - |
Applying recommendations
- Click Re-analyze to read the latest statistics.
- Tick the recommendations you want to apply.
- Tick Restart MariaDB now if needed. This is required and ticked automatically for values marked needs restart, for example
innodb_log_file_size. - Click Apply selected, then confirm.
Values are written to /etc/my.cnf.d/99-moorcp.cnf. Without a restart, values are applied live when possible. Every apply is validated by mariadbd and then health-checked. If MariaDB is unhealthy, the previous file is restored automatically.
Managed parameters: max_connections, max_user_connections, innodb_buffer_pool_size, innodb_log_file_size, max_allowed_packet, tmp_table_size, max_heap_table_size, wait_timeout, table_open_cache, thread_cache_size, query_cache_type, query_cache_size, slow_query_log, and long_query_time.
Restarting MariaDB
A restart drops all database connections for a few seconds. Websites can briefly show connection errors. Do it in quiet hours.
On an external endpoint, all recommendations are advice only and the my.cnf editor is not shown.
my.cnf editor
For options not covered by tuning, use the my.cnf editor card. The options are stored in /etc/my.cnf.d/zz-moorcp-custom.cnf and loaded last, so they override the panel's settings.
Write options under a
[mysqld]or[mariadb]section. Example:ini[mysqld] innodb_flush_log_at_trx_commit = 2Click Preview changes to see the diff.
Click Validate, save and restart, then confirm.
If mariadbd rejects an option, the error message points to the wrong line and your text stays in the editor. If MariaDB does not come back up, the previous file is restored automatically.
Not allowed:
- sections other than
[mysqld],[mariadb],[mariadbd], and[server]; !include;- file and directory paths (
*_file,*_dir,*_path),datadir,tmpdir,secure_file_priv; - plugins,
init_file,init_connect; user,socket,port,skip-grant-tables,skip-networking,log_bin,local_infile, and SSL file options.
Version history and rollback for this editor are in Service configuration, target "MariaDB: my.cnf editor".
Running queries
Settings › Databases also has a Running queries (all accounts) card: a live list of MariaDB and PostgreSQL connections per account, refreshed every 5 seconds, with Stop to cancel a query or close a connection. With a shared external endpoint, each server only lists and stops connections of its own accounts. Per-account database load over time is shown in Resource usage. See Resource usage › Database load.
Slow queries
The Slow queries (all accounts) table shows the slowest queries on the server, from the MariaDB slow query log.
- Queries are grouped by database and query shape.
- Literal values are replaced with
?, so customer data is not shown. - Columns: query, database, user, count, total/max time, average rows examined, and last seen.
- Period: the last 24 hours or 7 days.
TIP
Turn on slow_query_log through the tuning recommendations if this table is empty. Queries that read many rows usually need an index on the columns in WHERE or JOIN.
Table maintenance per account
The Database optimizer card is in the account's Databases tab (admin) and on the client panel's Databases page.
Table maintenance
Choose an action for one database:
| Action | MariaDB | PostgreSQL |
|---|---|---|
| Check | Checks the tables. | Dead row report per table. |
| Analyze | Updates statistics. | ANALYZE |
| Optimize | Rebuilds tables (InnoDB: recreate + analyze). | VACUUM (ANALYZE) |
| Repair | Repairs tables. Tables are locked briefly. | REINDEX DATABASE |
The result is a status per table. Every action is recorded in the audit log.
WARNING
Optimize and Repair can lock tables. Run them outside busy hours.
Tables that need attention
The Tables that need attention card flags tables that:
- have no primary key;
- have no index at all (1,000 rows or more);
- still use MyISAM;
- have a lot of wasted space or dead rows.
The card also shows the slow queries of that account only.
MySQL Governor (CloudLinux)
On CloudLinux servers, MySQL Governor limits MariaDB usage per account. Accounts that exceed their limits are put into their own LVE. The MySQL Governor card is in the CloudLinux tab of the server's details.
Installing
- Read Before you install:
- MariaDB packages are replaced with the CloudLinux build of the same version, and MariaDB restarts;
- all databases are dumped first to
/var/backups/moorcpon the server.
- Leave Start in monitoring mode (off) ticked.
- Click Install MySQL Governor, then confirm.
Only admins can install it. The install takes a few minutes. If it fails, the card shows the log and the database backup location, with a Retry install button.
Modes
| Mode | Behavior |
|---|---|
| off | Only monitors and records usage. Nothing is restricted. |
| abusers | Accounts that exceed their limits are restricted to their LVE. |
TIP
Start in off mode. Move to abusers once the limits look right against real usage.
Limits
Click Edit on Default limits or on an account's row. Fill in:
- CPU (%; 100 = one core);
- Read (MB/s) and Write (MB/s);
- Slow SELECT limit (seconds): only applies when stopping slow queries is on.
The panel fills the current-period limits. The short, mid, and long limits are derived automatically with CloudLinux coefficients.
Other per-account actions: Ignore, Watch, Use default, and Unrestrict. Unrestrict all releases every account that is currently restricted.
Stopping slow SELECT queries
Turn on Stop slow SELECT queries to stop SELECT queries that run longer than the account's limit. Governor checks periodically, so a query can run a little longer than its limit. Queries other than SELECT are not stopped. Turning this feature on or off restarts db_governor.
Database user map
Governor maps MariaDB users <account>_* to accounts. The map is updated automatically every 10 minutes. Click Sync user map to update it now, for example after creating a new database user.
INFO
Long queries that were already running before the account was restricted are not moved into the LVE. Use slow query stopping for cases like that.
