O'Reilly logo

Managing & Using MySQL, 2nd Edition by Hugh E. Williams, Randy Yarger, George Reese, Tim King

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required