MySQL Employees sample db up in 40 seconds

kommradHomer
2 min readOct 4, 2021

--

I took a screenshot of a webp beacuse medium cannot handle webp

If you are following some tutorials on databases, you might need a sample database for mysql. You might have already heard MySQL Employees Sample db , even if It’s not as famous as the Northwind db on MSSQL. Good news, I’ve created a docker image with mysql and employees db, kommradhomer/mysql-employees-db, should be up and running in about 40 seconds, depending on your specs and bandwidth.

You can start your container with the command below:

docker run --name myimage -e MYSQL_ROOT_PASSWORD=p -d -p 3306:3306 kommradhomer/mysql-employees-db

The command above will create a mysql with user=root and password=p and expose the default 3306 port for mysql, running as daemon. You can connect to the db with a mysql client on the host as below:

$ mysql -uroot -pp -h 127.0.0.1      
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use employees;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from employees limit 5;
+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_date |
+--------+------------+------------+-----------+--------+------------+
| 10001 | 1953-09-02 | Georgi | Facello | M | 1986-06-26 |
| 10002 | 1964-06-02 | Bezalel | Simmel | F | 1985-11-21 |
| 10003 | 1959-12-03 | Parto | Bamford | M | 1986-08-28 |
| 10004 | 1954-05-01 | Chirstian | Koblick | M | 1986-12-01 |
| 10005 | 1955-01-21 | Kyoichi | Maliniak | M | 1989-09-12 |
+--------+------------+------------+-----------+--------+------------+
5 rows in set (0,00 sec)

mysql>

BEWARE: It’s not best practice to keep data in a container or an image but I aimed to keep things simple

--

--

kommradHomer
kommradHomer

Written by kommradHomer

proud seeder of 146.5GB The.Lord.of.the.Rings.Trilogy.1080p.Extended.Complete.Bluray.DTS-HD-6.1.x264-Grym

No responses yet