In order to handle the administration of MySQL over the web, phpMyAdmin is a free software tool that is written in PHP. Wide range of operations on MySQL and MariaDB are supported by phpMyAdmin. Various operations like managing databases, tables, columns, relations, indexes, users etc can be performed through its user interface and also can execute any SQL statement. Generally, the database consists of one or more tables. Special CREATE privileges are needed to create or delete a database in phpMyAdmin in the following order:
Create a database in phpMyAdmin
Open localhost dashboard and click on phpMyAdmin.
Now create a database either through MySQLi or manually. In order to do it manually, click on databases and create a new one.
You can also change privileges and set up a new user login to access this database by clicking on add user account as shown in the screenshot below
You can also create a database using MySQLi procedural as shown in the example below:
// Create connection $conn = mysqli_connect($servername, $username, $password); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } // Create database $sql = "CREATE DATABASE mydatabase"; if (mysqli_query($conn, $sql)) { echo "Database created successfully"; } else { echo "Error creating database: " . mysqli_error($conn); } mysqli_close($conn); ?>
Database Created Successfully
Delete a database in phpMyAdmin
Go the phpMyAdmin home page and select the database which you want to delete. Now select operations and click on drop the database as shown in the screenshot below.
You can also drop the database using SQL query as shown in the screenshot below:
DROP DATABASE mydatabase;
With this, we come to an end of this How to Create and Delete a Database in phpMyAdmin article. I hope you have learned about how to create and delete a database in phpMyAdmin by manually and also by using a query.
Check out the PHP Certification Training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. It will give you a good understanding of PHP.
Got a question for us? Please mention it in the comments section of this article and I will get back to you.