Deleting a MySQL Database: 5 Steps (with Pictures)

Table of contents:

Deleting a MySQL Database: 5 Steps (with Pictures)
Deleting a MySQL Database: 5 Steps (with Pictures)
Anonim

To delete a MySQL database you must be logged in as root user or as a user with delete permissions. Type 'mysql -u username -p' in the terminal of MySQL, enter your password and delete the database with the command 'DROP DATABASE name database;'

Steps

Delete a MySQL Database Step 1

Step 1. Log in as a user with permissions to delete in the database in question

If there is no user with these access rights, you can log in as root user.

Delete a MySQL Database Step 2

Step 2. Go to the terminal view (command prompt in Windows) with the MySQL Command Line Client and type 'mysql -u username –p'

Delete a MySQL Database Step 3

Step 3. Enter your password when prompted

Delete a MySQL Database Step 4

Step 4. Type 'DROP DATABASE database name;'

Delete a MySQL Database Step 5

Step 5. Check if the database has been removed with the command 'SHOW databases;' and look at the list of visible users

Tips

  • Optionally you can use the command 'DROP DATABASE IF EXISTS name database;' to use. This prevents an error message in case the database does not exist.
  • If you are connecting to a database that is not localhost, use 'mysql -u username -h nameofhost –p'.
  • If you don't have permission to connect you can connect directly to a database with the command 'mysql -u name database –p'.
  • If you have the MySQL Workbench you can double click on a connection after logging in to go to the database overview. Right click on the top level (name of database) and click on drop schema to drop the database.

Popular by topic