Sakila: a sample SQL dataset
I learned today about the Sakila sample database. It has a non-trivial, but understandable schema, which is helpful when practicing SQL commands.
It is also easy to download and install.
- ivanceras / sakila has instructions for multiple DBMS
- As an sqlite3 file.
- Even as preloaded containers.
To try out this, we can easily run 2 containers: the first will run the DBMS and the data, and we will log to the other one to access the CLI. First we create a shared network so they can communicate:
docker network create --driver bridge mysql-net
Then the DBMS pre-loaded with Sakila:
docker run -p 3306:3306 -d --network mysql-net --name sakiladb sakiladb/mysql:8
Now, I couldn’t find an official container just with the CLI. But here’s a simple Dockerfile:
FROM ubuntu:latest
RUN set-x; apt-get update; apt install -y mysql-client; rm -rf /var/lib/apt/lists
And here we launch it:
docker run --rm -it --network mysql-net jzer7/mysql-client
Both containers share the same network (mysql-net
), so each is visible to the other under the container name.
So the argument for -h sakiladb
is the host that has the DBMS.
(The passwords are the defaults shown in the Dockerfile.)
mysql -h sakiladb -u sakila -p
Update: If you prefer a graphical interface, you can replace step 3, and use PHP My Admin.
docker run --name phpmyadmin --network mysql-net -d -e PMA_HOST=sakiladb -p 8080:80 phpmyadmin
Then just launch your browser to http://0.0.0.0:8080/.
When you are set, you can try your SQL proficiency with some questions from a Sakila test.