# Set a custom WordPress database table prefix in xCloud

> Choose the database table prefix for a new WordPress site in xCloud, see what the field accepts, and fix the 'already has a WordPress site' refusal.

You set the table prefix when you create a WordPress site: open **'Advanced Settings'** on the new site form and edit **'Database Table Prefix'**. WordPress adds this text to the start of every table name, so a prefix of `shop_` gives you tables such as `shop_options` and `shop_posts`.

This guide is for anyone creating a WordPress site who needs a specific prefix, or who sees a prefix error on the form. If you have no reason to change it, keep the generated value. It's harder to guess than the WordPress default of `wp_`, but it doesn't make a site secure by itself.

## What the field accepts

| Rule | Details |
|---|---|
| Characters | Letters, numbers and underscores only |
| Length | 32 characters at most, including the ending underscore |
| Ending | Must end with an underscore. If you leave it off, xCloud adds it, so `shop` becomes `shop_` |
| Default | A random four-character prefix, such as `gnmf_` |

## Set the prefix on a new site

### Step 1: Open the new site form

Go to **'Sites' → 'Add New Site'**, select **'WordPress'**, then **'Install New WordPress Website'**, and choose your server under **'Where should it run?'**, then click **'Continue'**. For the full walkthrough, see [how to create your first WordPress site](/docs/how-to-create-a-site-with-xcloud/).

**Expected result:** You see the site form, with **'Site Details'** and **'Configuration'** sections.

### Step 2: Open Advanced Settings

Under **'Configuration'**, click **'Advanced Settings'**.

![Click 'Advanced Settings' under 'Configuration' on the new WordPress site form](/_landing/docs/set-a-custom-wordpress-database-table-prefix-in-xcloud-image-1.png)

**Expected result:** The section opens and shows the admin details, versions, **'Site User'** and **'Database Table Prefix'**.

### Step 3: Enter your prefix

Replace the value in **'Database Table Prefix'**, or leave the generated one.

![The 'Database Table Prefix' field in 'Advanced Settings', showing a generated prefix](/_landing/docs/set-a-custom-wordpress-database-table-prefix-in-xcloud-image-2.png)

**Expected result:** The field shows your prefix with no error.

### Step 4: Create the site

Finish the other fields and click **'Next'**.

**Expected result:** xCloud checks the prefix and the database, then opens the site's progress page. If it refuses, the form stays open and shows the reason under the field. See [Fix a refused prefix](#fix-a-refused-prefix).

### Step 5: Check the result

When the site is ready, open **'WordPress' → 'WP Config'** from the site's menu and find the `$table_prefix` line.

![The table prefix line on the 'WP Config' page, under 'WordPress' in the site menu](/_landing/docs/set-a-custom-wordpress-database-table-prefix-in-xcloud-image-4.png)

**Expected result:** The line shows the prefix you chose. The screenshot shows a site that uses `wp_`.

## Fix a refused prefix

| Message on the form | What it means | How to fix it |
|---|---|---|
| **This database already has a WordPress site with the table prefix ... Choose another prefix or an empty database.** | The database you selected already has a table named with this prefix followed by `options`, such as `wp_options`. | Enter a different prefix, or choose an empty database. |
| **The table prefix may only contain letters, numbers and underscores, and must end with an underscore (for example: wp_).** | The prefix has another character, such as a hyphen or a space. | Remove that character. |
| **The table prefix may not be greater than 32 characters.** | The prefix is too long. The underscore counts. | Shorten it. |
| **The table prefix is required.** | The field is empty. | Enter a prefix. |
| **Another site on this server already uses this database name. Choose a different name.** | **'Database Name'** belongs to another site on the server. This message is about the name, not the prefix. | Enter a different database name. |

xCloud refuses a prefix that's already in use because the install would otherwise connect the new site to the existing site's data. Your existing database isn't changed when this happens.

You can see this with either **'Database Management'** option: **'Add Your Existing Database'**, or **'Create Database In Server'** when you enter the name of a database that already exists.

xCloud checks again during installation, so the same message can also stop an install that has already started. **'Retry'** on the progress page keeps the same prefix and database, so it doesn't clear this message. Create the site again with a different prefix or an empty database. The site name must be free on that server, so use another name, or ask our [support team](/docs/access-built-in-support-portal-in-xcloud/) to help you remove the failed site. If you delete a failed site yourself, turn off **'Delete Database'** in the delete window, or it can remove the database you wanted to keep.

![The 'Database Table Prefix' field showing the message that the database already has a WordPress site with the prefix wp_](/_landing/docs/set-a-custom-wordpress-database-table-prefix-in-xcloud-image-3.png)

For more on connecting your own database, see [how to add an external database](/docs/how-to-add-external-database-on-xcloud/).

## Migrated sites keep their prefix

Migration keeps the source site's table prefix and doesn't rename existing tables. You also see **'Database Table Prefix'** on the automatic migration settings form. The field shows a generated value, not the source site's prefix, and the note under it explains that the source prefix is kept. To review the migration settings, see [how to migrate an existing WordPress website](/docs/migrate-an-existing-wordpress-website-in-xcloud/).

## Sites that already exist

xCloud has no setting that renames the tables of an existing site.

The `$table_prefix` line in **'WordPress' → 'WP Config'** tells WordPress which tables to read, and it must match the tables in the database. Editing it doesn't rename anything. If you change the line so it no longer matches, the site stops working until it matches again.

Use the line in these two cases:

- **The line and the tables don't match.** Check the table names in [your site database](/docs/access-site-database-using-adminer-xcloud/), set `$table_prefix` to match them, and click **'Update Config'**.

  **Expected result:** The line shows the prefix of your tables. The site loads normally and you can log in to wp-admin.

- **You want a different prefix on a live site.** This is a manual database job, and these steps are general WordPress guidance rather than an xCloud feature. Take a [backup](/docs/site-backups-in-xcloud/) first, and try it on a [staging site](/docs/how-to-create-a-staging-environment-in-xcloud/) before you touch the live one. Rename every table yourself. Then update the saved settings that include the old prefix: the `user_roles` entry in the options table, and the `capabilities` and `user_level` entries in the user meta table. Each of these names starts with the prefix. Review plugins with custom tables too. Then set `$table_prefix` in **'WordPress' → 'WP Config'** to the new prefix and click **'Update Config'**.

  **Expected result:** The site loads normally and you can log in to wp-admin.

## For developers

The Public API and MCP accept an optional `prefix` when you create a WordPress site with `POST /api/v1/servers/{uuid}/sites/wordpress`.

- Leave it out and xCloud generates a random four-character prefix.
- The same rules apply: letters, numbers and underscores, 32 characters at most. xCloud adds a missing ending underscore.

## Frequently asked questions

### Do I have to change the generated prefix?

No. xCloud fills in a random four-character prefix, such as gnmf_, and the site works with it. Change it only if you have a reason to use a specific prefix, such as wp_.

### Does a custom table prefix make my site secure?

No. A generated prefix is harder to guess than wp_, but it does not protect a site by itself. Keep WordPress, plugins and themes updated, and keep backups.

### Does migrating a site change its table prefix?

No. Migration keeps the source site's table prefix and does not rename existing tables.

### Can xCloud rename the tables of a site that already exists?

No. xCloud has no setting that renames the tables of an existing site. The $table_prefix line in WP Config must match the tables already in the database.

If you run into any issues, feel free to reach out to our [support team](/docs/access-built-in-support-portal-in-xcloud/).
