Skip to main content
phpMyAdmin Guide
CHAPTER 04 Beginner

How to Create Databases & Tables in phpMyAdmin

Updated: May 16, 2026
15 min read

# CHAPTER 4

Creating Databases and Tables

1. Introduction

Every great software application begins with an empty database. In traditional SQL, creating a database and defining the tables requires typing out long, perfectly formatted CREATE DATABASE and CREATE TABLE commands. One missing comma, and the terminal throws an error. phpMyAdmin eliminates this frustration. In this chapter, we will use the visual GUI to instantly create our first database, configure its character set, and architect our very first tables without writing a single line of SQL code.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Create a new Database via the GUI.
  • Understand and select the correct Collation (Character Set).
  • Create a new Table within a database.
  • Define columns and data types visually.
  • Understand database naming conventions.

3. Creating Your First Database

Creating a database in phpMyAdmin takes exactly two clicks.
  1. 1. Open phpMyAdmin (http://localhost/phpmyadmin).
  1. 2. In the left sidebar, click the New button (at the very top of the database tree).
  1. 3. The main screen will display "Create database".
  1. 4. Enter a name in the "Database name" text box (e.g., company_db).
  1. 5. Leave the "Collation" dropdown as its default value, or select utf8mb4_unicode_ci (more on this below).
  1. 6. Click the Create button.
*Congratulations! You just created a database. It will instantly appear in the left sidebar.*

4. Naming Conventions

Before you type a name, you must understand the industry rules for naming databases and tables.
  • Lowercase Only: Always use lowercase letters. (Company_DB is bad; company_db is good).
  • No Spaces: Never use spaces. Use underscores (_) to separate words. (my store is bad; my_store is good).
  • Plural Tables: A database name is singular (company_db), but table names should almost always be plural nouns because they hold multiple records (users, products, orders).

5. What is Collation (Character Sets)?

When you create a database, you see a dropdown box next to the name filled with strange terms like latin1_swedish_ci or utf8mb4_general_ci. This is the Collation. It tells the database how to store and sort text characters.

The Golden Rule: Always select utf8mb4_unicode_ci (or utf8mb4_general_ci). Why? Because utf8mb4 supports every language on Earth (Chinese, Arabic, Russian) AND it supports Emojis! If you use older collations like latin1, and a user types a 🚀 emoji into a comment, your database will crash or corrupt the data.

6. Creating Your First Table

Now that company_db exists, click on it in the left sidebar. The main screen will say: "No tables found in database. Create table".
  1. 1. Name: Type users.
  1. 2. Number of columns: Type 3.
  1. 3. Click the Create button.

7. Defining the Table Structure

You will now see a grid where you define the architecture of your new users table. Fill out the first row (the primary key):
  • Name: type id
  • Type: select INT (Integer/Number)
  • A_I: Check the box that says A_I (Auto Increment). This tells MySQL to automatically count 1, 2, 3 as new users are added. Checking this box automatically makes it the Primary Key!

Fill out the second row:

  • Name: type username
  • Type: select VARCHAR (Variable Character text)
  • Length/Values: type 50 (Maximum 50 characters)

Fill out the third row:

  • Name: type email
  • Type: select VARCHAR
  • Length/Values: type 150

Scroll down and click Save. You have successfully architected a database table without writing any SQL!

8. Mini Project: Student Management Database

Let's practice the workflow.
  1. 1. Click New and create a database named school_system using utf8mb4_unicode_ci.
  1. 2. Inside school_system, create a table named students with 4 columns.
  1. 3. Configure the columns:
  • student_id (INT, check the A_I box)
  • first_name (VARCHAR, Length 100)
  • last_name (VARCHAR, Length 100)
  • enrollment_date (Type: DATE)
  1. 4. Click Save.

9. Common Mistakes

  • Forgetting the Length for VARCHAR: If you set a column type to VARCHAR, MySQL *requires* you to define a maximum length (e.g., 255). If you leave the Length/Values box empty and click Save, phpMyAdmin will throw a bright red SQL error. INT and DATE do not strictly require manual lengths, but VARCHAR always does.

10. Best Practices

  • The "id" Column Rule: Every single table you ever create in your life should have its very first column named exactly id (or tablename_id), set to INT, and with the A_I (Auto Increment) box checked. This ensures every row has a unique mathematical fingerprint (Primary Key).

11. Exercises

  1. 1. According to industry naming conventions, should a table containing customer data be named Customer, CustomersData, or customers?
  1. 2. What happens if you check the A_I (Auto Increment) box for an INT column in phpMyAdmin?

12. Database Challenges

You are creating a database that will be used by a global audience spanning Europe, Asia, and the Middle East. Furthermore, users will be allowed to use Emojis in their profile bios. What specific Collation must you select when creating this database in phpMyAdmin to prevent data corruption? *(Answer: utf8mb4_unicode_ci or utf8mb4_general_ci)*

13. MCQ Quiz with Answers

Question 1

When creating a new database in phpMyAdmin, why is it strongly recommended to select utf8mb4 as the Collation rather than the older latin1 default?

Question 2

When defining a table structure via the phpMyAdmin GUI, what is the mandatory requirement if you select VARCHAR as the data type for a column?

14. Interview Questions

  • Q: Explain the purpose of checking the A_I (Auto Increment) checkbox in the phpMyAdmin table creation GUI. What structural database constraint does phpMyAdmin automatically apply when this box is checked?
  • Q: Discuss database naming conventions. Why do experienced database administrators vehemently avoid using uppercase letters and spaces when naming databases and tables?

15. FAQs

Q: I created a table, but I misspelled the name. Do I have to delete it and start over? A: No! You can easily rename it. Click on the table in the left sidebar, click the "Operations" tab at the top of the screen, and look for the "Table options" section where you can rename it instantly.

16. Summary

You have built your foundation. You understand that clicking the "New" button, selecting utf8mb4, and utilizing the visual table builder allows you to rapidly deploy professional-grade database architectures while avoiding the syntax errors of raw SQL programming.

17. Next Chapter Recommendation

We created our tables perfectly the first time. But in the real world, business requirements change. What if the boss asks you to add a "Phone Number" column to the users table after it is already built? In Chapter 5: Managing Table Structures and Columns, we will learn how to modify existing tables using the Structure tab.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·