How to create database in phpmyadmin

We have seen many apps uses any specific backend database or services which are used to store data of the app within itself. In this article we will take a look on creating a new SQL database in phpMyAdmin so that we can perform CRUD operations using that database. 

In this article we will be simply setting our SQL database in which we will be performing CRUD operations through our Android Applications. For this, we will be creating a database using XAMPP on localhost.

Prerequisites : You should be having XAMPP installed on your system so that we can open phpMyAdmin and run it on local server. 

Step by Step Implementation :

Step 1 : Start your XAMPP server as shown in below screen

For starting your server on Xampp, we simply have to start the services in the Xampp console which is shown on below screenshot. 

After starting this services type localhost in your search bar and a page will open. On this page click on phpMyAdmin option which is shown in below screenshot.  

Step 2 : Creating a new database

Click on New option which is shown in below screen. After that we have to enter our database name and then click on Create option to create a new database. 

After creating a new database we have to move forward for creating a new SQL table. 

Step 3 : Creating a new table for storing our data

After creating your database, see below screen. In this screen we will be creating a new table. For creating a new table specify your table name and number of columns. In our case we are specifying our table name as courseDb and specify the number of columns as 4. The 4 different columns are as follows. The 1st column is for id, 2nd column is for courseName, 3rd column is for courseDescription and 4th column is for courseDuration.  

 After clicking on Go option your table will be created. Now we have to add column heading for our SQLite table. For adding this column heading you will get to see below screen. 

Steps to Create the SQL table :

  1. Enter the name for your columns in name section which is shown in above screen.
  2. After that enter the datatype of the data which we will be adding in our database. In this we are specifying INT for our ID as our ID will be an integer. And in SQL table VARCHAR is used for storing strings.
  3. In the length/ values section we have to specify the maximum length of the data which we will be adding in our table. We will not be specifying length for our ID because it is added automatically.
  4. After that we have to auto increment our ID. For this we have to check the box which is shown in above screenshot so that it will be incremented automatically on adding new data.

Now our database has been created successfully.

Home and Learn: PHP Programming Course

Create a database with phpMyAdmin

You can create all of your database tables and queries using PHP code. But before doing that, it's a good idea to get an understanding of just what it is you'll be creating. If you're new to the world of databases, then here's a simple primer.


What is a database and what do they look like?

A database is a way to store lots of information. You might want to store the names and addresses of all your contacts, or save usernames and passwords for your online forum. Or maybe customer information.

When you create a database, you're creating a structure like this:

The columns [ID, Title, First_Name, Surname] are called Fields. The rows are called Records. Each record is a separate entry.

In a database, you save the information in a Table. A single database can contain many tables, and they can be linked together. When the tables are linked together, it's said to be a relational database. If you just have a single table in your database, then it's called a flat-file database. Flat-file database are easier to create and understand, so we'll start by creating one of these using phpMyAdmin.

So start your server and bring up phpMyAdmin, if you havaen't already. Log in with your username and password [the password is blank, if you haven't changed anything.]

Although it looks a bit muddled, the part to concentrate on is the textbox under the words create new database, as in the next image:

If you can't see a section "Create new database", click New on the left-hand side of phpMyAdmin:

Type a name for your database, where it says "Create database". Type addressbook:

After you have typed a name for your new database, click the "Create" button. You will be taken to a new area. This, in older versions:

And this, in newer versions on phpMyAdmin:

In this new area, you can create a Table to go in your database. At the moment, as it says, there are No tables found in the database. But the database itself has been created.

To create a new table, type a name for it in the box at the bottom. You can also type a number for the Fields textbox. The fields are the columns, remember, and will be things like first_name, surname, address, etc. You can always add more later, but just type 4 in there. In fact, type it out exactly as it is below:

When you've finished, click the Go button. Another, more complex, area will appear:

Or this, in later versions:

In this new area, you set up the fields in your database. You can specify whether a field is for text, for numbers, for yes/no values, etc. We'll see how to do that in the next part.

Back to the PHP Contents Page

How do you create a new database?

On the File tab, click New, and then click Blank Database. Type a file name in the File Name box. To change the location of the file from the default, click Browse for a location to put your database [next to the File Name box], browse to the new location, and then click OK. Click Create.

How do I create a new database in MySQL database?

We need to follow these steps to copy a database to another database:.
First, use the CREATE DATABASE statement to create a new database..
Second, store the data to an SQL file. ... .
Third, export all the database objects along with its data to copy using the mysqldump tool and then import this file into the new database..

How do I start MySQL in phpMyAdmin?

Open your browser and go to localhost/PHPMyAdmin or click “Admin” in XAMPP UI. Now click Edit privileges and go to Change Admin password, type your password there and save it. Remember this password as it will be used to connect to your Database.

How do I manually create a table in phpMyAdmin?

To create new tables inside a database, open the phpMyAdmin tool, click on the Databases tab and click on the name of the desired database. On the new page that opens you will see a list of all the current tables inside the database and a section named Create table.

Chủ Đề