PHP and MySQL (49 Blogs) Become a Certified Professional

How to Create and Delete a Database in phpMyAdmin

Published on Sep 20,2019 14 Views

MI-new-launch

myMock Interview Service for Real Tech Jobs

myMock-mobile-banner-bg

myMock Interview Service for Real Tech Jobs

  • Mock interview in latest tech domains i.e JAVA, AI, DEVOPS,etc
  • Get interviewed by leading tech experts
  • Real time assessment report and video recording

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.

XAAMP-DownLoad

Now create a database either through MySQLi or manually. In order to do it manually, click on databases and create a new one.

Create New Database

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

add user account

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);
?>

 

//Output:

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.

drop database -in phpMyAdmin

warning - database-in-phpMyAdmin

You can also drop the database using SQL query as shown in the screenshot below:

DROP DATABASE mydatabase;

sql querries

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.

Comments
0 Comments

Browse Categories

Subscribe to our Newsletter, and get personalized recommendations.