Difference between revisions of "How to Create and Delete a MySQL Database"

From Brian Nelson Ramblings
Jump to: navigation, search
(Created page with "==How to create and delete a MySQL Database== Now that you have MySQL setup, I would assume that you will want to create a database. ===Create a New MySQL Database=== The...")
 
(Delete/Drop a MySQL Database)
Line 26: Line 26:
  
 
  drop database <databasename>
 
  drop database <databasename>
 +
 +
To verify that it has been dropped
 +
 +
show databases;
  
 
===Alternative way to create and drop a database===
 
===Alternative way to create and drop a database===

Revision as of 18:09, 12 March 2014

How to create and delete a MySQL Database

Now that you have MySQL setup, I would assume that you will want to create a database.

Create a New MySQL Database

The first thing you will need to do is login into mysql

mysql -u <username> -p

Then you will want to create your database

create database <databasename>;

To verify that your database has been created run:

show databases;

Delete/Drop a MySQL Database

As before, the first thing you need to do is login to mysql

mysql -u <username> -p

Then drop the database

drop database <databasename>

To verify that it has been dropped

show databases;

Alternative way to create and drop a database

Alternatively this can also be done with -e flag with mysql

mysql -u <username> -p -e'create database <databasename>'

or

mysql -u <username> -p -e'drop database <databasename>'