Databases are one of the building blocks of WordPress. They provide a way to not only store lots of information in one place but organize it into tables, sorted into columns and rows. A database can contain a single table, hence the name “flat-file database”, or be linked or exist alongside other tables, in which case it’s named a “relational database”. In the past, you needed knowledge of SQL (Structured Query Language) to not only create one but do anything within a database. And while advanced users still can, others have plenty of GUI-based alternatives, one of which is phpMyAdmin. With that said, let’s get into how to create a database using phpMyAdmin.
1. Access phpMyAdmin
Before you can make your first database, you must open phpMyAdmin. Opening phpMyAdmin depends on the location of your hosting:
Have you installed WordPress locally i.e., on your computer? We commend you for that; it’s always best to test things on a local machine before making them public. Depending on your operating system, you’ll need to use LAMP (Linux), WAMP (Windows), MAMP (Mac), or XAMPP (all-in-one). To encompass all our readers at once, we’ll demonstrate the process with XAMPP:
- Launch XAMPP Control Panel.
- Click on Start under “Actions” in the rows for Apache and MySQL (under “Module”).
- Wait a few seconds until [mysql] and [Apache] are marked as “Status change detected: running”.
- Click on Admin under “Actions” for MySQL to launch phpMyAdmin.
- Note. You can also skip 4, and enter one of the following URLs into your web browser:
- http://your-public-IP-address/phpmyadmin, e.g., http://22.214.171.1249/phpmyadmin (if you made your server public for testing)
The procedure is endlessly easier when you’re using a web hosting provider. You merely have to sign in to the cPanel (or a custom version they offer) on your web hosting service website. Then, click on phpMyAdmin in the “Databases” section.
2. Log in to phpMyAdmin
This most likely won’t be necessary on the web-based cPanel. If it is, either check your e-mail for details or contact your hosting’s Customer Support. On localhost, however, you might have to choose a language and a server type (MySQL). if this is your first time launching phpMyAdmin, the username will be “root” and the password blank. Otherwise, enter the custom username and password you chose within the Apache distribution software before clicking on Go. First-time users should immediately change it by clicking on Change password in the “General settings” section.
3. Create a database using phpMyAdmin
You’re finally ready to begin creating a database via phpMyAdmin:
- Click on New in the top left corner, below “Recent” and “Favorites”.
- Enter the name for your database in the text field.
- If you have a set of rules for strings that belong to a character set, select it from the drop-down list by clicking on Collation.
- Note. “utf8_general_ci” is the most commonly used UTF-8 collation.
- Click on Create.
- The database is empty, so it’s time to add your first table.
- Enter its name and number of columns then click on Go.
- Under “Type”, you can choose INT (integer i.e., numbers) or VARCHAR (variables/characters/letters), depending on what you plan to store.
- In “Lengths/Values” enter a number that represents the maximum length or value of a character or number.
- Optional. You can add:
- Table comments: Help yourself and others remember the table’s purpose or add some notes.
- Collation: make the table have a different collation/character set than the database.
- Attributes: Add properties to a table column.
- Null: Make the column “nullable” i.e., potentially have no value.
- A_I: makes the value of a field increase when a new item is added.
- Index: Add a directory where the table’s index files will be stored.
- Click on Save.
- You successfully made a database and a table using phpMyAdmin. Going forward, remember to backup WordPress databases regularly.