PHPMatters Help You Better Hosting Your PHP-based Sites
How to Create a Database in phpMyAdmin

How to Create a Database in phpMyAdmin

We have already introduced to you what is phpMyAdmin in our previous article, telling you why it is popular and how to install this PHP based application successfully. Here, we’d like to continue this tutorial concerning about how to create a database in phpMyAdmin. Note that we simply assume you make use of the most popular and user-friendly cPanel control panel.

How Does Database Look like?

A database is a collection of data that is well-organized. With it, you can store lots of information like your email accounts, username, password, contacts information, and many more. After creating the database, you can see the structure like the example displayed in the following.

database structure

The columns (id, username, sign_up_date, email, bio, account_permissions, email_activation) are fields, and the rows are records. Note that each record is a separate entry.

Create a Database in phpMyAdmin

In fact, phpMyAdmin offers an intuitive and easy-to-handle user interface, with which you can create a database with ease. The process requires 3 steps in total, and we have presented them in the following.

Step One – Enter phpMyAdmin

This contains 2 situations. If you have a hosting company, then you can enter this tool that is pre-installed from the control panel directly. For instance, if your control panel is cPanel, then you can find phpMyAdmin from the Databases section. After finding the right icon, simply click it.

phpMyAdmin icon

However, if you are managing a barebone web server on your own, then you have to install it manually. To enter phpMyAdmin, you can open your browser, type http://localhost/phpmyadmin into the address bar, and log into the script using your username and password.

Step Two – Create a New Database

After logging in, you can see a clear interface carrying a MySQL Localhost section. In the section, you are allowed to create a new database by entering the name into the blank field. Note that you’d better leave the default of collation for each of the fields. After filling into the database name, you need to click the Create button.

create database

Step Three – Create a Table

Now, you need to create a table for your newly-built database by entering the table name and enter the fields number in the next screen. Then, click the Go button.

Create Table

This is what you can see in the next page, requiring you to enter the field name, type, length/value, default, collation, attributes, null, and action. We are going to explain them one by one in the following.

  • Field – Each field needs a name. The most common field names are ID, first name, username, sign up date, email address, bio, account permission, and email activation.
  • Type – The types you have picked for the data can be stored, among which text, bigint, varchar, datetime, int, tinyint are the most widely used types.
  • Length – This section requires you to enter the value of a specific field. Note that the default length of INT type is 11 and varchar type is 255.
  • Default – This specifies whether to set the default value for the field. If not, then choose the None option, otherwise choose the As Defined option.
  • Collation – There is no need to change this section as it is pre-determined when you create your new database.
  • Attribute – The common attributes are BINARY, UNSIGNED, and UNSIGNED ZEROFILE. You can choose one based on your field.
  • Null – This specifies whether to contain anything into your field. If you set a field to NOT NULL, then you cannot leave it blank.