Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1

Figure 4.3 Dropping a database.


mysqladmin


Like many things in the computer world, there is more than one way to accomplish a task in MySQL. MySQL
offers a powerful utility that can help with the creating and dropping of a database—mysqladmin. This utility
also provides many other useful functions; you will learn about some of those functions in later lessons. For
now, you will create and drop a database using this utility.
Creating a database with mysqladmin is very simple. To create the sample database do the following:



  1. Make sure the mysqld daemon is running and that you are in the mysql directory.

  2. Type the following command to create the sample database:

  3. bin/mysqladmin –p CREATE sample_db
    Your output should look like Figure 4.4.


Figure 4.4 Creating a database using mysqladmin.


Dropping a database is just as easy. To delete the sample database, do the following:


  1. Again, make sure the mysqld daemon is running and that you are in the mysql
    directory.

  2. Enter the following command to DROP the database:

  3. bin/mysqladmin –p DROP sample_db
    Your output should resemble that shown in Figure 4.5.

Free download pdf