MySQL database in phpMyAdmin
Whenever we think of backend, the ‘database’ is the first word that strikes our mind. It acts as a key component in almost all domains. The main aspects of having a database are storing and retrieving data. So here we are going to create a MySQL database and then retrieve the necessary data using SQL queries in phpMyAdmin.
So to get started with creating a database turn on the Apache and MySQL modules from the XAMPP control panel. if you are unfamiliar with the XAMPP server then don’t worry, go through “Temporary Web-Hosting using XAMPP and ngrok”.
Now, as our XAMPP server has been started successfully, follow the steps given below to proceed further.
Creating a new MySQL database in phpMyAdmin:
Step-1: Open ‘localhost’ on your browser.
Step-2: Open ‘phpMyAdmin’ from the navbar of localhost dashboard.
phpMyAdmin is a free and open-source MySQL administration tool. It provides both the features of performing the operations with a user interface as well as by executing the SQL queries.
Step-3: Click on the ‘New’ button on the left side of the page.
Here enter the name of the database and then click on ‘Create’.
Once the database is created successfully, the name of the database will be shown at the left pane and you will see that the database is empty. A warning will be shown “No tables found in database”.
In the next section, we are going to create a new table in our database using the SQL statements.
Creating a new table in the MySQL database:
Step-1: Click on the ‘SQL’ button in the navbar.
On this page, we can run all the SQL queries.
Step-2: Creating a table with whatever name you want, like I have created a table named “Details” that contains three columns: Id, Name and Email_id.
Now proceed by clicking on ‘GO’.
Step-3: Once the table is created successfully, we will now enter the data in our table.
Step-4: Click on ‘GO’. When the data will be entered successfully, you will get the message “5 Rows inserted.”. The number of rows will vary based on the number of rows you enter like ‘5’ in the above example.
As the table is created and the data is entered successfully, in the next part we will be running the SQL queries for retrieving the desired data from the table.
Running Queries in MySQL:
1. Displaying the whole table using the ‘SELECT’ statement.
2. Selecting the column ‘Name’ to display only names in the table.
Similarly, you can perform all the desired operations for your MySQL database in phpMyAdmin using the XAMPP server.
#Learntocode Happy Learning!😊