Blog

3 Tips For Working With a MySQL Database!

Pre-Flight Check

  • These instructions are intended for deleting a MySQL database on Linux via the command line.
  • I’ll be working from a sxi.io Web Core Managed CentOS 7 server, and I’ll be logged in as root.

 

First, we’ll log in to the MySQL server from the command line with the following command:

mysql -u root -p

In this case, I’ve specified the user root with the -u flag and then used the -p flag so MySQL prompts for a password. Enter your current password to complete the login.

If you need to change your root (or any other) password in the database, then follow this tutorial on changing a password for MySQL via the command line.

You should now be at a MySQL prompt that looks very similar to this:

mysql>

Follow this tutorial if you have not yet created a database, or you want a list of databases.

Delete a Database in MySQL

It only takes one simple command to delete a database in MySQL, but BEWARE; dropping a database can not be undone! The command is as follows:

DROP DATABASE tutorial_database;

If a database of the name tutorial_database does not exist, then you’ll receive this error:

ERROR 1008 (HY000): Can't drop database 'tutorial_database'; database doesn't exist

To avoid seeing this error use the following command instead:

DROP DATABASE IF EXISTS tutorial_database;

The above command will only drop the database tutorial_database if a database of that name exists.

View All MySQL Databases

To view a list of databases simply issue the following command:

SHOW DATABASES;

Your result should be similar to this:

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

Series Navigation

<< Select a MySQL Database on Linux via Command LineHow to Back Up MySQL Databases From The Command Line >>

Related posts

Poll: 48% Believe Bitcoin Will Be Worth Over $500 by 2016

Viking Coin

Judge Orders Trading Firm, CEO to Pay $2.5 Million in Bitcoin Ponzi Case

Viking Coin

Bitcoin is Now Trading at its Highest Price Since 2014

Viking Coin

The RadicalxChange Movement’s Crypto-Cypherpunk Appeal

Viking Coin

OpenBSD: Configure Network Interface As A Bridge / Network Switch

Viking Coin

Interpol Event to Discuss Bitcoin’s Role in Illicit Asset Trade

Viking Coin

Chile’s State-Owned Bank Cutting Ties with Crypto Exchanges

Viking Coin

Linux / Unix: Display First Line of a File

Viking Coin

Bitcoin Processors Reconsider Marijuana Stance After New FinCEN Ruling

Viking Coin