home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeManaging and Using MySQLSearch this book

3.2. Database Creation

To get started using MySQL, you need to create a database. First, let's take a look at the databases that come with a clean MySQL installation using the SHOW DATABASES command. Upon installation of MySQL 3.23.40, the following tables already exist:

mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql    |
| test     |
+----------+
2 rows in set (0.37 sec)

The first database, mysql, is MySQL's system database, which you will learn more about in Chapter 5. The second database, test, is a play database you can use to learn MySQL and run tests against. You may find other databases on your server if you are not dealing with a clean installation. For now, however, we want to create a new database to illustrate the use of the MySQL CREATE statement:

CREATE DATABASE TEMPDB;

and then to work with the new database TEMPDB:

USE TEMPDB;

Finally, you can delete that database by issuing the DROP DATABASE command:

DROP DATABASE TEMPDB;

You can create new objects using the CREATE statement and destroy things using the DROP statement, just as we used them here.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.