Click Here to Turn Your Development Passion into a Real Career.

Create MySQL Databse with cPanel and phpMyAdmin

This tutorial will show how to create and populate a basic database using cPanel and phpMyAdmin.

First log in to your cPanel account and click on the icon that says MYSQL Databases
Create MySQL Databse with cPanel and phpMyAdmin tutorial

You should now see a screen showing your mySQL information.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

We will need to create the database. I will call my database test. Under current Databases in the New Database field type the name of your database, test.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

Then select create database, you will be forwarded to a screen that tells you the database was added. Click the go back button to return to management screen.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

Now you should see your new database listed under current databases. Notice the naming convention of my database teamc42_Test. This is the (cpanel user)_(database name). The reason that my databases are named that way is because we are using shared hosting for our test site. If you are using a shared hosting package your databases will be named in a similar manor, to keep you ‘test’ database separate from another users ‘test’ database. If you are on a dedicated host the database name will probably just be ‘test’.

In order to access the data we need to add a user and give the user a password. I will call me user ‘testuser’ instead of just ‘test’ to avoid confusion with the actual database. Enter the username and password and then click the ‘Create User’ button.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

You will be forwarded to a page telling that the user was added. Click the go back button to return to the previous page.

You will now see that you have a user and a database listed under ‘Add users to your database’. Now we will do just that, add the user to the database. Select the user select your test user and your database. We will give the user all permissions, so check the all permissions box. When you are finished click add user to database. You will be forwarded again and cPanel will let you know that a user was added to the database, click the go back button.

When you return to the Account Maintenance Screen you will now see that you have a user added to your database, and you will also see that cPanel gives you the connection strings for Perl and PHP.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

Our database has been created successfully, but now we need to add some sample data. To do this, scroll down to the bottom of the Account Maintenance Screen and click the phpMyAdmin Link. You should be redirected to the phpMyAdmin screen.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

On the left you will notice that is says “No tables found in the database”. We need to add a table so that we can add some data. Click on the link for your test database on the left (teamc42_Test in my case).

We can now create a table in our database. I will call my table ‘TestTable’ and give the table 4 fields and then hit the go button.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

Now we can add the information for our table fields. For the first line we will create an ID field. We will make this field the primary key. The primary key must be a unique value so we will make the ID field an auto generated integer. Enter the following information:

Field: ID
Type: Integer
Length/Values: 4
Collation: (blank)
Attributes: (blank)
Null: Not Null
Default: (blank)
Extra: auto_increment

Then we will select the option button for primary key (pictured below).
Create MySQL Databse with cPanel and phpMyAdmin tutorial

Then enter the following information for the other 3 fields.

Field 2
Field: FName
Type: Varchar
Length/Values: 30
Collation: (blank)
Attributes: (blank)
Null: Null
Default: (blank)
Extra: (blank)

Field 3

Field: LName
Type: Varchar
Length/Values: 30
Collation: (blank)
Attributes: (blank)
Null: Not Null (this tells mySQL that you must enter a last name)
Default: (blank)
Extra: (blank)

Field 4
Field: PHON
Type: Varchar
Length/Values: 12
Collation: (blank)
Attributes: (blank)
Null: Null
Default: (blank)
Extra: (blank)

When you are finished hit the save button. You should see the following information:
Create MySQL Databse with cPanel and phpMyAdmin tutorial

We can now add data to the table. Click TestTable on the left menu.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

Now click the insert button located at the top of the screen.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

You can now enter your test data. Remember to leave the ID field blank because it will be auto generated.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

I will enter two records and then click the go button. MySQL will tell you that the data was inserted.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

To view the data in your table click the browse button at the top. The data should be displayed like below.
Create MySQL Databse with cPanel and phpMyAdmin tutorial

You have successfully populated your table. You can now close the window. The next step would be to build to access the data through a web application (I prefer PHP). If you return to the Account Maintenance screen you will see that cPanel has given yout he connection string if you would like to get started. I will continue this tutorial to show you how to access the data later on. Look for a part 2 to this tutorial soon.