You can add one or more fields (columns) to an existing database table in phpMyAdmin. Open the table, choose where the new field goes, and enter its name and type. This article assumes you are already logged in to phpMyAdmin.
phpMyAdmin is a web tool for managing MySQL and MariaDB databases. You can use it to view and change database tables without writing SQL commands.
Before you start
- Log in to phpMyAdmin. Use a database user with the privileges you need, not the root account.
- Back up your database first. This is especially important for WordPress databases, because changing tables by hand can break a site.
- Check which control panel your plan uses. Hostking plans use cPanel or DirectAdmin, depending on the plan. Steps for each panel are in the sections below.
Add fields to a table
cPanel
- Log in to your account at https://my.hostking.host, then open cPanel.
- In the Databases section, click phpMyAdmin.
- In the left-hand panel, click the database name.
- Click the table you want to change.
- Click the Structure tab.
- Below the table's field list, find the Add section.
- Enter the number of fields you want to add in the box.
- Choose where the new field goes: At End of Table, At Beginning of Table, or After. If you choose After, select an existing field from the drop-down menu.
- Click Go.
- Enter the name and type for each new field. See the example below.
- Click Save.
DirectAdmin
The steps for DirectAdmin may differ from cPanel. Log in to your DirectAdmin account at https://my.hostking.host, open phpMyAdmin from the Databases section, and look for the table structure view. If you cannot find it, contact support using the steps in the Troubleshooting section.
Example: adding an address field
Suppose you want to add a field to store a customer's address. Give the field the name address.
- Name:
address - Type:
CHAR(character) - Length: 100 or more, so that longer addresses fit in the field
A CHAR field has a fixed length. If you expect longer values, consider VARCHAR instead.
Troubleshooting
- Error when saving: Check that the field name is unique in the table and that the length is valid for the type you chose.
- Changes do not appear: Click the table name again to reload its structure.
- Need help: Use live chat on the website, available 7 days a week from about 05:00 to 20:00 UTC, or open a support ticket from the client area at https://my.hostking.host.
