Databases Reference
In-Depth Information
$
mysql --user=root --password=
the_mysql_root_password
< count_users.sql
count(*)
4
Loading the Sample Databases
To get a working sample database that you can play with, start by visiting the topic's
web site and downloading the music database file
music.sql
from the sample databases
section.
To load the file into your server, you need to use the
SOURCE
command and specify where
MySQL can find the
music.sql
file. For example, this might be
~/music.sql
or
~/Desktop/music.sql
on a Linux or Mac OS X system, or
C:\Documents and Settings
\my_windows_login_name\Desktop\music.sql
on a Windows system.
Once you run the
SOURCE
command, you should see some reassuring messages flash by:
mysql>
SOURCE
path_to_music.sql_file
;
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.01 sec)
Query OK, 1 row affected (0.00 sec)
...
You can now see if the database is there by using the
SHOW DATABASES
command:
mysql>
SHOW DATABASES;
+----------+
| Database |
+----------+
| music |
| mysql |
| test |
+----------+
3 rows in set (0.00 sec)
mysql>
We'll see how to use this database in future chapters.
Repeat this process for the two additional sample database files,
flight.sql
and
univer-
sity.sql
, that are available from the topic's web site. Finally, you can leave the MySQL
monitor by typing
quit
:
mysql>
quit
MySQL Monitor Program Options
The monitor program can take several parameters; the ones you'll need most frequently
are: