Install Sakila database

This article shows how to download the Sakila database script and import it into the MySQL server.

Before installing the Sakila database, please install the MySQL server first.

Download the Sakila database

You can download the Sakila sample database from https://downloads.mysql.com/docs/sakila-db.zip.

Click the download link and a file in Zip format will be downloaded. The Zip file contains three files: sakila-schema.sql, sakila-data.sql and sakila.mwb.

  • sakila-schema.sql: The file contains all CREATE statements to create the structure of the Sakila database, including tables, views, stored procedures, functions and triggers.
  • sakila-data.sql: The file contains all INSERT statements to insert data.
  • sakila.mwb: The file is a MySQL Workbench data model. You can open it in MySQL Workbench to check the database structure.

Install Sakila database

Please follow the steps below to install the Sakila sample database:

  1. Unzip the downloaded zip file to a temporary location, for example C:\temp\ or /tmp/. When you unzip the archive, it creates a folder named sakila-db that contains sakila-schema.sql and sakila-data.sql files.

  2. Use the mysql command line client and the following command to connect to the MySQL server:

    mysql -u root -p
    

    Enter your password when prompted.

  3. Execute sakila-schema.sql to create the database structure and execute sakila-data.sql to insert the data into the database, by using the following command:

    mysql> SOURCE C:/temp/sakila-db/sakila-schema.sql;
    mysql> SOURCE C:/temp/sakila-db/sakila-data.sql;
    

    Replace the paths to the sakila-schema.sql and sakila-data.sql files with the actual paths on your system.

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

  4. Confirm that the sample database is installed correctly. Execute the following statement. You should see output similar to that shown here.

    USE sakila;
    
    Output
    Database changed
    
    SHOW FULL TABLES;
    
    Output
    +----------------------------+------------+
    | Tables_in_sakila           | Table_type |
    +----------------------------+------------+
    | actor                      | BASE TABLE |
    | actor_info                 | VIEW       |
    | address                    | BASE TABLE |
    | category                   | BASE TABLE |
    | city                       | BASE TABLE |
    | country                    | BASE TABLE |
    | customer                   | BASE TABLE |
    | customer_list              | VIEW       |
    | film                       | BASE TABLE |
    | film_actor                 | BASE TABLE |
    | film_category              | BASE TABLE |
    | film_list                  | VIEW       |
    | film_text                  | BASE TABLE |
    | inventory                  | BASE TABLE |
    | language                   | BASE TABLE |
    | nicer_but_slower_film_list | VIEW       |
    | payment                    | BASE TABLE |
    | rental                     | BASE TABLE |
    | sales_by_film_category     | VIEW       |
    | sales_by_store             | VIEW       |
    | staff                      | BASE TABLE |
    | staff_list                 | VIEW       |
    | store                      | BASE TABLE |
    +----------------------------+------------+
    23 rows in set (0.01 sec)
    
    SELECT COUNT(*) FROM film;
    
    Output
    +----------+
    | COUNT(*) |
    +----------+
    |     1000 |
    +----------+
    1 row in set (0.00 sec)
    
    SELECT COUNT(*) FROM film_text;
    
    Output
    +----------+
    | COUNT(*) |
    +----------+
    |     1000 |
    +----------+
    1 row in set (0.00 sec)