Difference between revisions of "How to Create and Delete a MySQL Database"
From Brian Nelson Ramblings
(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...") |
(→Alternative way to create and drop a database) |
||
(One intermediate revision by the same user not shown) | |||
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=== | ||
Line 36: | Line 40: | ||
mysql -u <username> -p -e'drop database <databasename>' | mysql -u <username> -p -e'drop database <databasename>' | ||
+ | |||
+ | Now just check and see if its there or been dropped | ||
+ | |||
+ | mysql -u <username> -p -e'show databases;' |
Latest revision as of 18:10, 12 March 2014
Contents
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>'
Now just check and see if its there or been dropped
mysql -u <username> -p -e'show databases;'