Pages Navigation Menu
No Risk, No Contracts! - Learn coding, Web Design and More!

Create MySQL Databse with cPanel and phpMyAdmin

Beautiful WordPress Themes

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.

  • Chris

    Thanks! This helped me a lot tonight.

  • http://www.mimzthings.com Mirian

    Thank you sooooooooooooooooooo much. I was looking for something like this for a while now. Now I will look for your part 2. Mirian

  • m azam

    i get a lot knowledge from here
    it a excellent site
    thanks

  • http://www.inmotsm.com Damian

    this is what ive been waiting for, this has helped me a lot, I just wish there was part 2, because im a little stuck now, Im starting to understand the hole thing a little better now, my email is damiencurtis@hotmail.com, can anyone tell me how to add the tables in to my website and then add a search bar.

  • http://www.teamtutorials.com John Ward

    I will try write part 2 of the tutorial soon. It will cover reading data from the database use php.

    • http://www.emmatech.com IZUAGBA EMMANUEL

      i want to know hw i will create a database without going to any computer school.

  • http://www.jeffersonrepublic.com Josh Freeman

    Thanks for the great tutorial John. I’m looking forward to “part 2″… Please hurry : )

    If you could give us an idea when you will post it, I would be thankful.

    Josh

  • http://www.inmotsm.com Damian

    still waiting

  • http://www.palaid.com sbaraqouni

    Really, It is very interesting

  • alie

    Just checking …when is the next or the 2 part of the tutorial.I thank you for the last one,,,,very gooooooooooooooooood ….

    C’ yah….

  • http://www.teamtutorials.com John Ward

    Sorry, it has been a little hectic around here lately. I am starting a new job. I will try to get part two up as soon as I can.

  • http://www.google.ru/ hiutopor

    Hi

    Very interesting information! Thanks!

    G’night

  • http://filipinocommunityireland.com jobuguina

    Thanks so much,

    I am only starting for the database for my site, this really help me so much

    God Bless

  • http://www.mrc.ac.uk Nitish Anand

    Good article on the databases. I was using the non-gui version but it helped me a lot. Further I would like to do is to send my users data from a html form to mysql database using the php script.

    thx.

  • http://www.almonjed.com isam

    hi thank you so much for your partisipation can you please give some examples how can make a tables in my website which we can access the database and retrave the data? thanking your efforts
    isam al hassan

  • http://todaywithevie eve

    this was a great!!! help :D
    thanks alot!!

  • http://www.thisishowyoudoit.com/blog/ Richard

    Great tips. In another lesson, I was doing everything through notepad and uploading via FTP each tme a change was made. It was taking awhile Good suggestions.

    Do you know of any good GUI applications I could use to enter my data into the database.? I downloaded one called Navicat, and run it locally on my machine, but it didn’t seem to able to connect to my dbase on the web.

  • http://infinity-ventures.com suresh

    Its provide good database help with pictures and coding method.

  • Pingback: Team Tutorials » Authentication with PHP/MySQL

  • http://home.com bob

    GnPHFd great site man thanks http://peace.com

  • http://www.tucsongrapevine.com/ Tuscon

    great panel options

  • http://www.world.cc Schools

    thanks for the great directions

  • http://link Szdrdqqj

    cool site 10x

  • http://link Gfhqrwpu

    Gloomy tales

  • http://link Wtymshuk

    good work man

  • Dave .E

    yeah! is nice i must say, 4real i’ve been hooked up for some while now because of this, but my way is through.
    thanx ‘ll

  • Erik

    Thanks for the tutorial. Big help.

  • http://link name

    comment5,

  • http://www.luv-emo.com/emofashion.html emo hair

    good tutorial. will favorite this

  • http://www.golfkurs.com Platzreife

    Nice tutorial bro..!!
    I was having some errors and your tutorials solved it in minute…

  • http://www.nuacco.net/resources/ More traffic

    Absolutely great, and it’s real slick and simple. I am using it now on my website!
    Thanks

  • http://saturnets.com paul

    that great… when will you part 2 be out or how can i locate it

  • http://www.lekensontech.net Lekan

    Thanks for this tutorial, i really enjoy and it really helped me alot , you guys are genious

  • http://SeattleAreaGroceries.com J.T. Thompson

    It takes talent to create such an excellent tutorial with newbies in mind. This one tutorial was a great help to me. Thanks Much!!!!!!!!!!!!!!!

    J.T.

  • http://www.environicsindia.in Mohit

    Was a lot of help. was easy to understand

  • http://www.scene-hairstyles.com Jennifer V.

    great info thanks

  • http://www.qalmidosti.com Sameer Shehzad

    Hi,
    It really very helpful
    Where is next level details.
    regards
    sameer

  • Ciaran Pender

    Hello

    This is a great tutorial and exactly what I have been looking for,although I am having a problem.At the very start of the tutorial you say to create a HTML file that links into the search.php file just to make sure that the variable entered into the search bar is displayed,well it won`t display my variable entered -it opens a new tab which remains blank.I know that it is connecting to the search.php page beacuse when I change form action=search.php in the HTML to form action = searc.php it tells me that there is an error where as when I enter the correct file name it remains blank-any ideas?

    Thanks alot

  • http://sbamicroloan.blogspot.com/ SBA

    Enjoyed the read, will bookmark.

  • http://www.claudiudesign.org/ Web Design Romania

    At first it might seem hard to work with phpmyadmin … but … it’s quite easy and you’ll agree with me once you get a little experience with it.

  • mundia

    What wonderful help, Danke

  • hoo

    Suuuuuupppper!!

  • http://wowtah.com Christine

    Omg I neeeeed a part 2. =P

  • http://www.designstrom.com Ravtan

    can you please give some examples how can make a tables in my website which we can access the database and retrave the data?

  • Supun

    Great work…….. im a newbie and was dying for this info

  • Usman

    Its really very good tutorial. It help me a lot get create a database.

  • rama

    thanx, really it helped me lot,
    great job

    keep going

  • babatunde

    good job man

  • Priya

    Thanks a lot. I was looking for a tutorial like this for a long time. It has helped me a lot.

  • mahendran

    i am use phpmyadmin and launch database to the web server . any option to access the server db through the local phpmyadmin

    • http://www.teamtutorials.com John Ward

      I believe you want to access a remote MySQL database locally. Unfortunately I do not know how to do this using PHP my admin. Have you tried Heidi SQL (http://www.heidisql.com/) yet? It the best GUI app I have found so far. In order to connect to a remote server using Heidi SQL you will need to be able to allow remote SQL access. If you have CPanel there is an option for remote SQL. If you do not know if you can do this ask you host if you can and how. I am also plannign to post a tutorial on how to do this if you host uses cpanel and allows remote SQL. Hope this helps.

  • Sanjay Gupta

    We create an array and store it in the variable $array. We then open a database and
    attempt to insert an element called “arraytest”, passing it the $array variable as the
    value. We then test the return type from dbmfetch() when attempting to access
    “arraytest” and ascertain that a string has been returned. In fact, if we printed the
    value stored in the “arraytest” record, we would get the string “Array”. That would
    seem to wrap up any hopes for storing arrays and objects.
    Fortunately, PHP provides a feature that allows you to “freeze-dry” values of any
    data type in string format. The data can then be stored in a database or file until it
    is needed. You can use this technique to store arrays and even objects in a DBM

  • http://www.bluelinesynergy.com sam

    thank you so much.coz i was ready to loose my job n coz of this tutorial,i worked out the problem

  • http://www.supplierevaluations.com Compare Suppliers

    Thanks for the tutorial its a lot of help.

  • http://www.pika.me Clay Jackson

    Thanks, this was really easy to follow!

  • zolu

    That was so good!

    where I can get part 2 ?

  • culvi

    Awesome clear tutorial. After three others this nailed it to the tee. Thanks for being very thorough! As a matter of fact, I am going to scour the rest of this site to see what I can learn. Thanks

  • Dave

    Hi John,

    Any luck on accessing MYSQL databases using Heidi remotely. I run a webserver but want to manage it from the home office as it is to slow through the Cpanel.

    • http://www.teamtutorials.com John Ward

      Yes you can access a remote MySQL database using Heidi. If you have access to the mysql console you can grant remote privs to a specific user and/or you can do it in CPanel there is an option for remote my sql. You will either have to add the IP you want to access it or allow all remote IP addresses using a wild card %. So if you al;ready had a user called testuser and a database called testdb you could run this from the mysql console:

      GRANT ALL ON *.testdb to ‘testuser’@’%’;

  • http://www.fibercementkaplama.com fibercement

    Great job.Thanks a lot.

  • http://www.sherayapi.com sove

    That was so good!..Thanks a lot.

  • http://tourcomedy.com/ tour comedy

    When you return to the Account Maintenance Screen the user added to your database can be seen, as well as the cPanel that gives the connection strings for Perl and PHP.

  • Naeem

    A Lot Of Thenx…….

  • Pooja

    This isvery helpful

  • http://www.sherayapi.com söve

    Great tutorial.Its my favorite site.Thanks.

  • http://www.webconnecttechnologies.com shiv

    Great
    very help full for fresher in php
    thank

    shiv kumar
    web developer
    http://www.webconnecttechnologies.com

  • http://www.d.com aaa

    dasdasd

  • nati

    wow! i get what i need. really thank you. am waiting part two………

  • Emmanuel

    Warning: require_once(Connections/fxtruth.php) [function.require-once]: failed to open stream: No such file or directory in /home/fxtruthn/public_html/newsletter.php on line 1

    Fatal error: require_once() [function.require]: Failed opening required ‘Connections/fxtruth.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/fxtruthn/public_html/newsletter.php on line 1

    • http://www.johnathanward.com John Ward

      That error is a simple one. It means that those files are not there and cannot be included. Check that you specified the correct path and file name.

      • Emmanuel

        I don’t understand pls, i want the website to be connected to my database. Thanks

      • http://www.johnathanward.com John Ward

        This is just how to create the database. Take a look at our PHP tutorials section for basic on how to connect to the database.

  • roy

    Hi!
    What are the softwares you are using and where can I get them?

  • SHIBI

    Thank you dude…….

  • David

    Thnx a lot.

  • shrikant suryawanshi

    i have problem at the database file hosting on server. the server gives the error page as below. So please give detail information to me which username and password will be written in database connection file.

    The page cannot be displayed
    The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
    ——————————————————————————–

    Please try the following:

    Contact the Web site administrator if you believe that this request should be allowed.
    Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
    HTTP Error 405 – The HTTP verb used to access this page is not allowed.
    Internet Information Services (IIS)

    ——————————————————————————–

    Technical Information (for support personnel)

    Go to Microsoft Product Support Services and perform a title search for the words HTTP and 405.
    Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Setting Application Mappings, Securing Your Site with Web Site Permissions, and About Custom Error Messages.

  • http://www.slothbob.com Jay Brid

    yes, good teacher here,

  • http://www.workintheuk.byethost3.com workintheuk

    it really makes sense.

  • http://www.20milesnorth.com Edward Washington

    just finished the first tutorial, worked like a champ so far, on to the php!

  • http://www.dreamdth.com Vikram

    Good ….

  • http://uidb.org acha

    can some one just kindly tell me how i can open the forms i have created. thanks and best regards

  • shirley peters

    problem… my data base does not show up anywhere. Where should it be? I am trying to install wordpress and it can’t fine the DB, and nor can I.

  • http://proddec.org Vinish Kumar

    Thanks a lot ,it really help
    can u explain us that can we handle database using java
    without the help of php and perl

  • http://www.hekimyapi.com fibercement kaplama

    good projected and amazing.

  • https://softubspas.co.uk Adam

    Very good tutorial. I’ve wanted to get in to mysql / php for years, and it’s all fallen in to place tonight.

  • PATEL NEETA

    THANKYOU VARYMUCH

    IT IS VERY EISY WAY TO UNDERSTAND TO THIS INFORMATION.

  • anonymous

    do u know how relations between tables work in phpadmin? I have a database that has a bunch of relations between tables but I have no idea how to get it to work using phpadmin..!

  • http://www.bina.com.tr söve

    very nice tuto.Thank u for sharing

  • Pingback: Ubuntu Linux » Blog Archive » Apache LAMP Server – PHP/MySQL Setup

  • http://www.ijsshr.com Marshal

    I am still having problem still. I have utilized the example you gave above. I have amended the password to mine but got this error after executing:
    Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /home/ijsshrco/public_html/assignments.php on line 22
    I wish i could upload my program as an attachment but i’ll post it all the same:

    Oteh’s Assignments

    <?php
    //make connection
    mysql_connect ("localhost", "ijsshco_assignments",
    "master123") or die ('I cannot connect to be database because: ' . mysql_error());
    mysql_select_db ("ijsshco_assignments");

    //build query
    $query = mysql_query("select * FROM contacts");

    //display results
    while ($row = mysql_fetch_array($query)){
    echo //tells php to print the results to screen
    "ID: “//html for label. Goes to new line and prints label
    .$row['ID']. //selects our first row data ID and prints it

    ” Name: “//more html just
    tells the web browser to go the next line.
    Line we print the label out.
    .$row['name']. //prints our name data
    ” School: ” //more html another break tag and label
    .$row['school']. //grabs school data from Database
    “Course Title: ” //
    .$row['course_title'] //prints Course Title data

    “Course Code: ” //
    .$row['course_code'] //prints Course Code Data

    “Course Title: ” //
    .$row['course_title'] //prints Course Code Data

    “Registration Number: ” //
    .$row['reg_no'] //prints Course Code Data

    “Email: ” //
    .$row['email'] //prints Course Code Data

    “Upload: ” //
    .$row['upload'] //prints Course Code Data
    “;} //final break and we close the loop.
    ?>

  • http://www.ijsshr.com Marshal

    i did a few more editing but got this error:
    Parse error: syntax error, unexpected $end in /home/ijsshrco/public_html/assignments.php on line 35

    My php code is as follows:

    Oteh’s Assignments

    <?php
    //make connection
    mysql_connect ("localhost","ijsshco_assignments","master123") or die ('I cannot connect to be database because: ' . mysql_error());
    mysql_select_db ("ijsshco_assignments");
    //build query
    $query = mysql_query("select * FROM contacts");
    //display results
    while ($row = mysql_fetch_array($query)){
    echo //tells php to print the results to screen
    "ID: “//html for label. Goes to new line and prints label
    .$row['ID']. //selects our first row data ID and prints it
    ” Name: “//more html just tells the web browser to go the next line. Line we print the label out.
    .$row['name']. //prints our name data
    ” School: ” //more html another break tag and label
    .$row['school']. //grabs school data from Database
    “Course Title: ” //
    .$row['course_title']. //prints Course Title data
    “Course Code: ” //
    .$row['course_code']. //prints Course Code Data
    “Registration Number: ” //
    .$row['reg_no']. //prints Course Code Data
    “Email: ” //
    .$row['email']. //prints Course Code Data
    “Upload: ” //
    .$row['upload']. //prints Course Code Data
    “;} //final break and we close the loop.

    ?>

  • http://www.jiple funscon

    how will i resolve this error in my web page Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user ‘jiplem’@’localhost’ (using password: NO) in /home/jiplem/public_html/Connections/jiplem.php on line 9

    Fatal error: Access denied for user ‘jiplemco’@’localhost’ (using password: NO) in /home/jiplem/public_html/Connections/jiplem.php on line 9

  • http://ownfreemovie.com Sampson

    Please can you help me out here, I have no knowledge of database creation, how do I add a title of a movie file to a database lets, say that the name of the movie is Thor, where in the table would I addd the title name

  • http://leanderhughes.com Leander Hughes

    Thanks a lot for this tutorial- very helpful!

  • Khan Taher

    i’m a new web designer, i want make a database for a subdomain of my main domain like. http://www.health.cancerbd.org 
    contact.
    khan.taher21@gmail.com

  • http://amwebbers.com srimali

    thank you very much, wonderful, i really enjoyed every step. Thank you

  • Pingback: How to Access a MySQL Database Using PHP