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:
- Make sure the mysqld daemon is running and that you are in the mysql directory.
- Type the following command to create the sample database:
- 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:
- Again, make sure the mysqld daemon is running and that you are in the mysql
directory. - Enter the following command to DROP the database:
- bin/mysqladmin –p DROP sample_db
Your output should resemble that shown in Figure 4.5.