• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Delete MySQL Database From Command Line

By Abhishek Ghosh September 3, 2014 2:35 pm Updated on September 3, 2014

Delete MySQL Database From Command Line

Advertisement

Here is how to delete MySQL database from Command Line Interface or SSH using MySQL drop database command. It is quite simple and easy. Previously, we have shown how to export WordPress MySQL Database on Rackspace Deployment using only Command Line Interface. MySQL by default has quite powerful interactive interface. PHPMyAdmin is a risk itself if run for production environment. Before the reader is going to delete MySQL database from Command Line, we recommend to take a backup of the whole server although if properly done, this can not be a risk to other databases.

 

Commands to Delete MySQL Database From Command Line

 

For example, in the guide for installing Piwik on nginx on Ubuntu 14.04 on Rackspace Cloud, we really installed Piwik on production environment and understood it is far from our expectation. Only recursively deleting the web software is not a good idea for security reasons. If you have old MySQL database, make sure the name is correct. References can be found here :

Vim
1
http://dev.mysql.com/doc/refman/5.0/en/drop-database.html

 
Delete MySQL Database From Command Line

First, SSH to the database server as server’s root user. MySQL root user might have different password. This command to login to MySQL as root usually works fine :

Advertisement

---

Vim
1
2
3
4
5
6
mysql -u root -p
# you are root, give password
# welcome message followed by
# mysql interactive mode like this
# mysql >
# will start

The syntax to delete MySQL database is :

Vim
1
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name

But we will run this to get the list of all databases :

Vim
1
2
3
4
5
show databases;
# will look like
mysql >
mysql > show databases;
# hit return or Enter key

It will return thing like this :

Vim
1
2
3
4
5
6
7
8
9
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| your-db-to-delete  |
| your-another-db    |
| your-db-to-here    |
+--------------------+

You want to delete that database named your-db-to-delete; in that case you’ll run :

Vim
1
2
3
4
5
6
7
8
9
drop database your-db-to-delete;
# alternate 1
# drop database your-db-to-delete
# alternate 2
# drop schema your-db-to-delete;
## will look like
mysql >
mysql > drop database your-db-to-delete
## hit return or Enter key

Again reload the databases :

Vim
1
show databases;

And flash the privileges :

Vim
1
FLUSH PRIVILEGES;

If you had an user WHO WAS THE ONLY USER OF THAT INTENDED TO DELETE DATABASE, you must delete it too :

Vim
1
2
3
4
5
drop user user_name;
# user_name is variable
# like abhishek
# like wordpress
# like foo

Again flush the privileges.

Tagged With mysql delete data from table command in centos from ssh , mysql drop database command , delete table data quickly using ssh in mysql , delete mysql databases ssh , delete database tables thorugh ssh , delete database ssh , delete database phpmyadmin command line , delete database in mysql from command line , ssh remove database , delete all data from wordpress database ssh
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Delete MySQL Database From Command Line

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Changing Data With cURL for OpenStack Swift (HP Cloud CDN)

    Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad.

  • OpenShift OctoPress Auto install Script

    OpenShift OctoPress Auto install Script is an Advanced Script to Run OctoPress on Free OpenShift PaaS Practically Without Any Knowing Ruby or Git.

  • OpenStack Swift & HPCloud CDN PHP Bindings : Basics

    Here is the basics of OpenStack Swift & HPCloud CDN PHP Bindings for the WordPress Plugin developers and those who works with PHP based CMS.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy