Creating Database books in MySQL
For each MySQL database we discuss in this book, we provide a SQL script that will set up the database and its tables. These scripts can be executed with a command-line tool called mysql that is part of the MySQL installation. In the examples directory for this chapter on the CD that accompanies this book, you will find the SQL script books.sql.
To create the books database:
- Open a Command Prompt and change to the C:mysqlin directory. [Note: If you installed MySQL on a directory other than C:mysql, replace C:mysql with your MySQL installation directory.]
- Start the database server by executing the command
C:mysqlin>mysqld
- Copy the SQL script books.sql to the C:mysqlin directory. [Note: If you installed MySQL on a directory other than C:mysql, replace C:mysql with your MySQL installation directory.]
- Open a new Command Prompt and change to the C:mysqlin directory. [Note: If you installed MySQL on a directory other than C:mysql, replace C:mysql with your MySQL installation directory.]
- Create the books database by executing the command
C:mysqlin>mysql -h localhost -u jhtp6 -p < books.sql
When the above command is executed, you are prompted for entering the password, which is jhtp6. After completing this task, a new directory named books will be created in the C:mysqldata directory. This new directory contains the books database. You are now ready to proceed to the first JDBC example.