Oracle/MSSQL/MySQL

How to delete and create MySQL Databases

How-to-create-and-delete-MySQL-database

According to Wiki, MySQL is an open-source relational database management system. A database is used to store the collection of records in an organized form. It allows us to hold the data into tables, rows, columns, and indexes to find the relevant information frequently.. In this article, you will learn how to delete and create MySQL Databases. Here are some exciting guides: How to update WampServer to Latest Version, how to Generate SSH keys in Windows 11, how to stop Docker from automatically starting on Mac, how To Set Up Public Load Balancer in Azure, and How to enable or disable Secure Boot in Windows. In this article, I will show you how to delete and create MySQL Databases.

Drop a MySQL Database

The DROP DATABASE statement drops all tables in the database and deletes the database permanently. Therefore, you need to be very careful when using this statement. The following shows the syntax of the DROP DATABASE statement.

Please see these related articles: How to access MySQL Server from command Prompt, Debugging: How to debug a PowerShell script, and how to download your MySQL database from Azure to a local PC with MySQL Workbench.

DROP DATABASE database_name;
run-query-to-drop-db

In this statement, you specify the name of the database which you want to delete after the DROP DATABASE keywords.

As you can see below, the database has been deleted.

drop-mysql-db

MySQL Remove DATABASE using MySQL Client

Note: Just as you can delete databases with DROP. You can use DROP to delete a user altogether as discussed here in “How to delete a MySQL User Account“. Please also see how to check and assign privileges to a MySQL User.

First, log in to the MySQL Server using the root user or with the useraccount that has the privilege to drop the database.

mysql>mysql -u [username]-p
mysql -u root -p

Next, you will have to display all the databases using the SHOW DATABASES statement:

SHOW DATABASES;

We will have to drop the DB we wish from the output above. We will now have to TechDADb by issuing the DROP DATABASE statement.

DROP DATABASE TechDADb;

To log out, type the following command “quit“.

mysql>quit

Note: You can also use the MySQL Workbench for this dropping and creating a new user account on MySQL.

Create a MySQL database from the phpMyAdmin

Launch the phpMyAdmin interface, and click on the Database Menu. Enter the Database name, select the Collation and hit the Create button.

This will ensure the database is created. 
newcollation

Note: Users are assigned to databases by editing the user record (from the User accounts link on the home page). If you are creating a user specifically for a given table you will have to create the user first (with no global privileges) and then go back and edit that user to add the table and privileges for the individual table.

Create a MySQL Database via the MySQL Commandline Client

Log in to the MySQL server as discussed above. Ensure to replace the name TechDA with your database name.

CREATE DATABASE TechDA;

To check the created database, please use the following query.

SHOW DATABASES; 

I hope you found this blog post helpful on how to delete and create MySQL Databases. If you have any questions, please let me know in the comment section.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x