cPanel's databases

Open cPanel. Find and open Tools > Databases > Manage My Databases.

Image. Tools > Databases.

Creating a DB

Next you'll create a new Database. Give the DB a name.

For naming conventions, use lower case letters. Numbers are ok, but no specials characters. For test DBs, use prefix 'test' or 'mysql'.

After naming, click Create Database. Save the full DB name to your txt file (created in previous chapter).

Image. Creating the DB.

Creating a User

Next you'll create a new User. Give the User a name and a password. Be sure to save both to your txt file.

This User's name and password are later used to access the DB with PHP.

Click Create User.

Image. Creating the User.

Adding the User to DB

Next you'll add the user to the Database.

Use the dropdowns to select the target database and the user that you just created.

Click Add.

Image. Adding the user to the DB.

User priviledges

You'll be asked about what priviledges should the user get for accessing the DB.

For this test, select All Priviledges.

Click Make Changes to confirm the priviledges.

Image. User priviledges.

Notes

Check your .txt notes that you got the names and the password saved. I'll share my example values here below so you can compare.

Image. My names for Database and User, and User password.

Creating a Table to the database

Open cPanel. Find and open Tools > Databases > phpMyAdmin.

Image. Tools > Databases.

Open your database in phpMyAdmin (which should be on the list in the left).

In the table creation window on the right, give the table a name (naming convention: lower case alphabet, numbers and underscore ok).

Next, set the amount of columns. For this example, I'll use three columns (for id, name and email).

Save also the table name in your .txt notes as it will be needed later.

Click Create.

Image. Creating a Table.

Defining the columns

Give each column a name. Beware, using reserved words as column names can create hurdles in future. (Keywords and Reserved words). Reserved words -list includes f.e. 'name', 'group', 'character', 'column', 'table', 'default', 'desc', 'index', 'key', etc..

Select also a fitting type for each column. Set max length for the value if possible.

Image. Creating a Table.

Check the checkbox to A_I if you want an auto-incrementing INT. I'll be using that for the user_id column in this example.

Image. Auto-incremented id.

After all of the columns are defined, click Save

NOTE

You can always come back and change column names, amount of columns, length, type etc.

DB - done.

Now you're done creating the DB, User and Table.

At this point, I've gathered all the names and values in my .txt file, which should be helpful during the PHP-part later.

Image. DB, User, Table.

In part 2 we will create a HTML form for accessing the DB!

1

2

3

4