Setting Up the world Database  /  Installation

2 Installation

To enable MySQL users to perform manipulation of this data set using MySQL, the data set is available as a set of three tables:

Note

For MySQL 5.7+ users, a world_x variant also exists that implements 5.7+ specific features related to the X DevAPI. That version is also available at http://dev.mysql.com/doc/index-other.html.

  • 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 file is available for download at http://dev.mysql.com/doc/index-other.html.

Note

Releases issued prior to September 2016 used table names in mixed cases. Now table names are all lowercase. This is because MySQL Shell is case-sensitive.

To install the world sample database, follow these steps:

  1. Extract the installation archive to a temporary location such as C:\temp\ or /tmp/. Unpacking the archive results in a single file named world.sql.

  2. Connect to the MySQL server using the mysql command-line client with the following command:

    shell> mysql -u root -p

    Enter your password when prompted. A non-root account can be used as long as the account has privileges to create new databases.

  3. Execute the world.sql script to create the database structure, and insert the data, by using the following command:

    mysql> SOURCE C:/temp/world.sql;

    Replace C:/temp/ with the path to the world.sql file on your system.

    Note

    On Windows, use slashes, rather than backslashes, when executing the SOURCE command.

  4. 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/.


PREV   HOME   UP