To enable MySQL users to perform manipulation of the
world
sample database using MySQL, the data set
is available as a set of three tables:
country
: Information about countries of the world.city
: Information about some of the cities in those countries.countrylanguage
: Languages spoken in each country.
The world.sql
file containing the
world
database is available for download at
https://dev.mysql.com/doc/index-other.html. The file is
provided as a compressed tar file or Zip
archive.
To install the world
sample database, follow
these steps:
Download the installation archive to a temporary location such as
C:\temp\
or/tmp/
and unpack it. Unpacking the archive results in a directory namedworld-db
containing a single file namedworld.sql
.-
Connect to the MySQL server using the mysql command-line client with the following command:
$> mysql -u root -p
Enter your password when prompted. A non-
root
account can be used, provided that the account has privileges to create new databases. -
Execute the
world.sql
script to create the database structure and insert the data using the following command:mysql> SOURCE C:/temp/world.sql;
Replace the path to the
world.sql
file with the actual path on your system.NoteOn Windows, use slashes rather than backslashes when executing the
SOURCE
command. -
To confirm that the sample
world
database is installed correctly, execute the following statements. You should see output similar to that shown here.mysql> USE world; Database changed mysql> SHOW TABLES; +-----------------+ | Tables_in_world | +-----------------+ | city | | country | | countrylanguage | +-----------------+ 3 rows in set (0.00 sec) mysql> SELECT COUNT(*) FROM city; +----------+ | COUNT(*) | +----------+ | 4079 | +----------+ 1 row in set (0.02 sec) mysql> SELECT COUNT(*) FROM country; +----------+ | COUNT(*) | +----------+ | 239 | +----------+ 1 row in set (0.00 sec)
You now have the world
sample database
installed.
Another popular sample database is the Sakila database. For additional details, see http://dev.mysql.com/doc/sakila/en/.