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 allCREATEstatements to create the structure of the Sakila database, including tables, views, stored procedures, functions and triggers.sakila-data.sql: The file contains allINSERTstatements 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:
-
Unzip the downloaded zip file to a temporary location, for example
C:\temp\or/tmp/. When you unzip the archive, it creates a folder namedsakila-dbthat containssakila-schema.sqlandsakila-data.sqlfiles. -
Use the mysql command line client and the following command to connect to the MySQL server:
mysql -u root -pEnter your password when prompted.
-
Execute
sakila-schema.sqlto create the database structure and executesakila-data.sqlto 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.sqlandsakila-data.sqlfiles with the actual paths on your system.On Windows, use slashes rather than backslashes when executing the
SOURCEcommand. -
Confirm that the sample database is installed correctly. Execute the following statement. You should see output similar to that shown here.
USE sakila;OutputDatabase changedSHOW 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)