RESTful Post: MySQL Database
Page 4
Create a Database
Overview
Learn to create a database with cPanel. Add a table and create columns with phpMyAdmin.
You'll create a database with cPanel, named db_test
and
a table within db_test
named,
TestColors
.
You'll define four columns named
user, pwd, data
and id
.
You'll assign the AUTO_INCREMENT feature to column id
.
cPanel: MySQL Databases
Load cPanel.
Select the icon next to
MySQL Databases
.
When the Create New Database
page displays,
enter a database name. For this tutorial we'll just
call it db_test
.
If you're not a user for the database then
add a new user and password, on the same page.
cPanel: phpAdmin
Return to the cPanel page and select phpMyAdmin.
phpMyAdmin
phpMyAdmin takes a few seconds to load.
Within phpMyAdmin, under db_test
select the New
button to create a new table.
For this example we'll name the table TestColors
because we're just going to let users input their favorite color.
The next section explains how to create the columns you see
in the following structure tab:
phpMyAdmin: Create Columns
Create four columns including an int
named id
and three VARCHAR
types with
length of 256
.
Name the columns,
user, pwd, data
and id
.
When you're done, select the structure tab and you should see the following four columns.
phpMyAdmin: AUTO_INCREMENT
Last assign the AUTO_INCREMENT feature to column id
.
Select the check box next to the id
column,
then select the Change
icon that displays a pencil.
You should see the following page. If you don't see
A_I
, then scroll to the right.
Select the A_I
column, which abbreviates,
AUTO_INCREMENT.
Now every time you add a row to the database, the id
field will increase by one.
Be sure you have selected None
for the Default
value of column, id
.
Summary
You learned to create a database with cPanel. You added a table and created columns with phpMyAdmin.
You created a database with cPanel, named db_test
.
You created a table within db_test
.
The table's name is TestColors
.
You created four columns named
user, pwd, data
and id
.
You assigned the AUTO_INCREMENT feature to column id
.
Try It!
Try the Post to PHP example described in this tutorial.