How to create a database using phpMyAdmin and XAMPP
Databases, PHP, Web Design
When working on a website that is either hosted or local on your computer, sometimes you’ll need a database for it. Back in the day, you would need to know SQL and how to run those commands in some sort of prompt. Nowadays, we have phpMyAdmin which is a graphical user interface for SQL. You can click, type in text boxes, and after a while, you’ll have a database created along with tables, columns, user permissions, etc.
To use phpMyAdmin, you’ll need to either install hosting software on your computer such as XAMPP, MAMP, LAMP, or WAMP. Or, you can get a web host that has it installed on it already. The “AMP” in those software packages stands for Apache (the web server), MySQL (the databases), and PHP. The M is for Macs, the L is for Linux, and the W is for Windows. XAMPP does them all so that’s the one I’d recommend starting out with.
As for web hosts, the one I use and HIGHLY recommend is interserver.net They are cheap, reliable, charge you monthly, and don’t hike up their prices like most of the other web hosts do.
In this blog post, I will only show how to create a Database with a table and some columns. However, at the top of this post, I inserted a video that shows a lot more than that. It goes into downloading/installing XAMPP, accessing phpMyAdmin, creating a database, and using PDO (PHP Data Objects) to connect to it. Now, onto showing how to use phpMyAdmin!
To access phpMyAdmin from XAMPP you will need to make sure you have Apache and MySQL running in the XAMPP control panel by clicking the start buttons under the Actions column:
If Apache and MySQL are green then all is well. Then you can click the “Admin” button in the MySQL row and that will launch phpMyAdmin:
You can also access phpMyAdmin by typing in http://localhost/phpmyadmin/ into your browser. The first time you access it, you will need to login using “root” as the username and there will be no password. Once you’ve typed that in, click on “Go”:
Once you are logged in I would recommend changing your password to secure your databases and their settings:
After you’ve done that. You will want to create a new database by clicking here:
You will then be prompted to name the database, do so, and then click on “Create”:
Then you will be asked to create a table with however many columns you want. Once you’ve decided that, click “Go” again:
This will require that you preplan your database a bit. You’ll need to know exactly what you will be storing in it. For this example, we will be storing the user’s name and age. So on the next screen we will put in a names and ages column. We will also need to give them a type, age will be INT (integer/numbers) and names will be VARCHAR (characters/letters). Finally we will need to say how many characters can be in each column. Age will be 3 since I don’t think anyone would live to be older than 999 (: and we will give 100 characters for their name which should be enough. Once we filled in those fields, we would click “Save”:
And there you have it! A new database with a table with two columns in it ready to be filled. Be sure to watch the video at the top of this post if you want to see how to connect to the database using PHP Data Objects (PDO). Also, be sure to check out our PHP Training Course if you want to learn more about PHP, databases, and how to use them together. Have an amazing day!