How to Install the Employees Sample Database in MariaDB
To install the employees sample database in MariaDB, download and extract test_db, start the MariaDB client from the directory containing employees.sql, then run SOURCE employees.sql;. The script drops and recreates any database with that name, so use a separate practice server without an existing employees database.
Download and extract the sample files
The sample contains fictional employees, departments, job titles, and salary history. Employee and department numbers give you keys to practice joining tables. Allow space for both the extracted files and the tables and indexes on the server.
- Open the test_db repository on GitHub and choose Code → Download ZIP.
- Extract the archive and find the directory containing
employees.sql,load_employees.dump,load_salaries1.dump, andshow_elapsed.sql. Keep the otherload_*.dumpfiles in the same directory. - Open a terminal and change to that directory. The client reads the files locally, so they belong on the machine running the client.
Connect to the MariaDB practice server and verify the target
The original employees.sql script starts by executing DROP DATABASE IF EXISTS employees. Running it against a production or shared server can affect existing data. Use a practice-server administrator authorized to create the database, tables, and views and flush the logs.
This example assumes a local practice instance on 127.0.0.1:3306 with TCP access configured for root. Substitute your practice instance’s port and account as needed. The MariaDB client option --abort-source-on-error stops the script when an import error occurs.
mariadb --host=127.0.0.1 --port=3306 --user=root --password --abort-source-on-error
Enter the password when prompted. If the practice instance on Linux authenticates root through a Unix socket, you can use sudo mariadb --abort-source-on-error from the same directory. Once connected, run the following SQL.
SELECT @@hostname AS server_host, @@port AS server_port,
@@datadir AS data_dir, VERSION() AS server_version;
SHOW DATABASES LIKE 'employees';
Compare the hostname, port, and data directory with the settings for your practice instance. Another server can also be running on 127.0.0.1. Proceed only if the first result identifies the intended instance and the second query returns no rows.
Run employees.sql
In the same MariaDB client session, enter the command below. SOURCE tells the client to read a local file and send its SQL to the server. The script loads its companion files by relative path, so the directory you started the client from matters.
SOURCE employees.sql;
Look for progress messages such as CREATING DATABASE STRUCTURE, LOADING employees, and LOADING salaries. The salary history can take time to load. When the prompt returns without errors, run the verification queries.
Check the tables and loaded data
Use SHOW FULL TABLES to check the object types and COUNT(*) to check the row counts of key tables. The name employees.employees refers to the employees table in the employees database.
SHOW FULL TABLES FROM employees;
SELECT COUNT(*) AS employee_count FROM employees.employees;
SELECT COUNT(*) AS department_count FROM employees.departments;
SELECT COUNT(*) AS salary_count FROM employees.salaries;
A complete import shows six base tables and two views. The views are current_dept_emp and dept_emp_latest_date. The original sample contains the following row counts in three key tables.
| Table | Expected rows |
|---|---|
employees |
300,024 |
departments |
9 |
salaries |
2,844,047 |
The database and tables can appear before all rows load. Comparing row counts helps reveal partial imports, for example when one of the salary files could not be loaded.
Troubleshoot import errors
mariadbcommand missing — Check that the client is installed and try using the executable in itsbindirectory. On Windows you can invokemariadb.exe.- Connection refused or authentication failed — Check that the practice instance is running, confirm the port, and check that the connection method matches the account’s authentication setup.
Failed to open file— Fully extract the archive, restart the client from the extracted directory, and check foremployees.sqland the file named in the error.- Permission error — Read the failing statement and use an account with the required create and log privileges on the practice server.
ERROR 1064nearto_date— MariaDB 12.3.3 treatedto_dateas a reserved word, which can break the original column definition. Check the server version and retry on a clean practice instance using MariaDB 12.3.4 or a newer 12.3 patch release. MariaDB’s fix for the reserved word
A failed import can leave tables and some data behind. Use the first error to diagnose the problem, then repeat the target check and import on a clean practice instance.



