Setting Up the world_x Database  /  Installation

2 Installation

To enable MySQL users to perform manipulation of the world_x sample database using MySQL, the data set is available as a set of four tables:

  • country: Information about countries of the world.

  • city: Information about some of the cities in those countries.

  • countrylanguage: Languages spoken in each country.

  • countryinfo: Information about each country represented as a JSON document.

The world_x.sql file containing the world_x 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.

Note

The world_x database uses features specific to X DevAPI, and thus requires MySQL 5.7 or higher. A world database variant also exists that does not use X DevAPI features and may be used with MySQL 5.5 and higher. See Setting Up the world Database.

To install the world_x sample database, follow these steps:

  1. Download the installation archive to a temporary location such as C:\temp\ or /tmp/ and unpack it. Unpacking the archive results in a directory named world_x-db containing files named README.txt and world_x.sql.

  2. Execute the world_x.sql script to create the database structure and insert the data using one of the following methods:

    • Using MySQL Shell:

      $> mysqlsh -u root --sql --file C:\temp\world_x-db\world_x.sql
    • Using the standard MySQL command-line client:

      Connect to MySQL:

      $> mysql -u root -p

      From the mysql client, load the file:

      mysql> SOURCE C:/temp/world_x-db/world_x.sql;

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

    Replace the path to the world_x.sql file with the actual path on your system.

    Note

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

  3. To confirm that the sample world_x database is installed correctly, execute the following statements. You should see output similar to that shown here.

    mysql> USE world_x;
    Database changed
    
    mysql> SHOW TABLES;
    +-------------------+
    | Tables_in_world_x |
    +-------------------+
    | city              |
    | country           |
    | countryinfo       |
    | countrylanguage   |
    +-------------------+
    4 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_x sample database installed.

Another popular sample database is the Sakila database. For additional details, see http://dev.mysql.com/doc/sakila/en/.