Java Reference
In-Depth Information
Note
On Windows, your MySQL database server starts every time your computer starts. You
can stop it by typing the command net stop mysql and restart it by typing the
command net start mysql .
stop mysql
start mysql
By default, the server contains two databases named mysql and test . The mysql database
contains the tables that store information about the server and its users. This database is
intended for the server administrator to use. For example, the administrator can use it to cre-
ate users and grant or revoke user privileges. Since you are the owner of the server installed
on your system, you have full access to the mysql database. However, you should not cre-
ate user tables in the mysql database. You can use the test database to store data or create
new databases. You can also create a new database using the command create database
databasename or delete an existing database using the command drop database
databasename .
32.3.2 Creating a Database
To match the examples in this topic, you should create a database named javabook . Here are
the steps to create it:
1. From the DOS command prompt, type
mysql -uscott -ptiger
to login to mysql, as shown in FigureĀ 32.8.
2. At the mysql prompt, enter
create database javabook;
F IGURE 32.8
You can create databases in MySQL.
For your convenience, the SQL statements for creating and initializing tables used in this
book are provided in Supplement IV.A. You can download the script for MySQL and save it
to script.sql . To execute the script, first switch to the javabook database using the following
command:
use javabook;
and then type
source script.sql;
run script file
as shown in FigureĀ 32.9.
 
 
Search WWH ::




Custom Search