• 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

This Article Has Been Shared 708 Times!

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

  • MySQL InnoDB Optimization From my.cnf

    On Rackspace Cloud Server PVHVM, We Can Further Optimize MySQL. Here are some performance tweaks for MySQL InnoDB optimization from my.cnf.

  • Installing WordPress on Rackspace Cloud Server with Cloud Database

    Installing WordPress on Rackspace Cloud Server with Cloud Database can give you a good performance with scalable and economically best solution. Simple Guide.

  • CRM SaaS and Market Trends

    CRM SaaS and Market Trends will remain stable despite there is fall in the SaaS consumption due to data theft and increased awareness of Privacy on Cloud.

  • Secure Cloud Computing : A Short Handy Guide

    Secure Cloud Computing is a Big Chapter. An Average User Need Not to Know All the Terminologies. Here is a Simplified Guide in Plain English.

  • zlib.output_compression Should Be Off on Cloud Server for Performance

    zlib.output_compression, Specifically for PHP-MySQL Web Software Like WordPress Should Be Off on Cloud Server for Performance. Here is Why.

Additionally, 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 (22.1K 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

  • Why You Need A Big Data Consultant May 15, 2022
  • The Connection Between AI And Online Slots May 13, 2022
  • How To Choose Your Niche As An Instagram Influencer May 12, 2022
  • How to Choose a Powerful Domain Name for Your New Venture May 12, 2022
  • How To Leverage Big Data In Social Media May 11, 2022

About This Article

Cite this article as: Abhishek Ghosh, "Delete MySQL Database From Command Line," in The Customize Windows, September 3, 2014, May 16, 2022, https://thecustomizewindows.com/2014/09/delete-mysql-database-from-command-line/.

Source:The Customize Windows, JiMA.in

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Privacy Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

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

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