> For the complete documentation index, see [llms.txt](https://docs.uxwizz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uxwizz.com/guides/troubleshooting/agency/multidb.md).

# MultiDB

### Problem:

Adding a domain fails when Agency multi-database mode is enabled:

```
Failed to create multi-db database. See error log for more.
```

### Cause:

The configured database account may not have permission to create a database and grant access to it. Connection failures, schema errors, or a non-writable mapping file can also stop provisioning.

UXWizz creates database names beginning with `uxdb_` and grants access to the database account that actually authenticated, including its host component.

### Solution:

This repair requires a database or server administrator. Dashboard access alone cannot change MySQL or MariaDB privileges.

1. Check the PHP error log for the failed operation and database server. Do not publish credentials or the full configuration file.
2. Check the server entry in `server/multidb/multidb-list.php`. Confirm the host, port, username, and connection from the UXWizz server.
3. Connect using that account and inspect its effective identity and grants:

   ```sql
   SELECT CURRENT_USER();
   SHOW GRANTS;
   ```
4. Have the administrator grant a dedicated account the rights needed to create and manage UXWizz databases, including the right to grant access to those databases. Use the MariaDB example below when it matches your server.
5. Check whether the failed attempt already created a database before retrying. Preserve existing data and mappings. After repair, add the intended domain and confirm it appears and accepts tracking data.

{% hint style="warning" %}
Do not create `root` access from every host or grant access to every database as a general fix. Do not delete a partially created database until the administrator confirms it is unused and backed up.
{% endhint %}

If your hosting plan does not permit database creation or grant management, ask the host about a supported configuration. Send [support](/guides/support.md) the UXWizz version and redacted error message if the failure continues.

See [MySQL GRANT documentation](https://dev.mysql.com/doc/refman/8.0/en/grant.html) for privilege scope and database-pattern behavior.

### MariaDB: grant the existing application account access

For MariaDB, a database administrator can grant the **existing** account access to the naming pattern used by UXWizz:

```sql
GRANT ALL PRIVILEGES ON `uxdb_%`.*
TO 'uxwizz'@'10.0.0.20' WITH GRANT OPTION;
SHOW GRANTS FOR 'uxwizz'@'10.0.0.20';
```

Replace the account and host with the exact result of `CURRENT_USER()` from the application connection. If it is a local account, its host might be `localhost`. This command does not create an account or change its password. Keep its access to the main UXWizz database too.

`WITH GRANT OPTION` is required because UXWizz grants access after creating each database. The pattern uses SQL wildcards: `_` matches one character and `%` matches the remainder. Reserve database names matching `uxdb_%` for UXWizz; it also matches names such as `uxdbXexample`. Do not use this pattern if unrelated databases share it.

This complete create-and-grant sequence was checked with MariaDB 11.8. Escaping the underscore to narrow the grant is not an equivalent fix: it can permit creation but reject the application's following `GRANT`. MySQL configurations, including `partial_revokes`, can treat database-pattern grants differently. Have the administrator test the exact server's behavior instead of copying this MariaDB-specific repair.
