# How to Import the Exercises Dataset into MySQL: A Complete Guide

> Easily import the exercises dataset into MySQL. This guide shows you how to use the provided SQL script to load all 1,324 exercise records with a simple terminal command.

- Repository: [Hasan Emir Yıldırım/exercises-dataset](https://github.com/hasaneyldrm/exercises-dataset)
- Tags: how-to-guide
- Published: 2026-07-31

---

**The `hasaneyldrm/exercises-dataset` repository ships a browser-based generator in [`setup.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/setup.html) that produces a ready-to-run SQL script containing all 1,324 exercise records, which you can load into MySQL with a single terminal command.**

This guide walks you through importing the complete exercises collection from JSON into a structured MySQL database. The repository's interactive Developer Setup Guide automates the schema creation and data insertion process, eliminating the need to write manual `INSERT` statements for the [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json) file.

## Step 1: Generate the MySQL Import Script

The repository includes an interactive tool at **[`setup.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/setup.html)** that transforms the raw JSON dataset into a standard SQL dump file.

Open [`setup.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/setup.html) in any modern browser and select the **MySQL** tab. Click the **Generate .sql** button to trigger the download. Internally, the page executes a fetch request to [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json), parses each of the 1,324 exercise records, and constructs a file containing a `CREATE TABLE` definition followed by individual `INSERT` statements for every row.

The generated script automatically maps JSON fields to table columns, including multilingual instruction fields (e.g., `instructions_en`, `instructions_es`), `equipment`, `category`, `image`, and `gif_url`.

## Step 2: Create the Target Database

Before loading the script, ensure your MySQL server has a database ready to receive the data. Connect to your MySQL instance and run:

```sql
CREATE DATABASE IF NOT EXISTS exercises_db;
USE exercises_db;

```

This creates a dedicated database named `exercises_db` and switches the active context to that database, ensuring the subsequent table creation occurs in the correct namespace.

## Step 3: Import the SQL Script into MySQL

With the database prepared, load the generated file using the standard MySQL client. Assuming you saved the download as [`exercises_mysql.sql`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/exercises_mysql.sql), execute the following from your terminal:

```bash
mysql -u <username> -p < exercises_mysql.sql

```

The client will prompt for your MySQL password. Upon authentication, MySQL executes the script sequentially: first creating the `exercises` table with the appropriate schema, then inserting all 1,324 records in a single transaction batch.

## Step 4: Verify the Data Import

Confirm successful import by checking the record count. Connect to your database and query:

```sql
SELECT COUNT(*) FROM exercises;

```

The query should return **1324**, indicating that all exercise entries from the original JSON file are present in the relational table.

You can immediately begin querying the structured data. For example, to retrieve dumbbell exercises sorted alphabetically:

```sql
SELECT name, equipment, category
FROM exercises
WHERE equipment = 'dumbbell'
ORDER BY name LIMIT 10;

```

## Understanding the Table Structure

The resulting MySQL table schema mirrors the structure defined in **[`data/exercises.schema.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.schema.json)**. Key columns include:

- **`id`** – Unique identifier for each exercise
- **`name`** – Exercise name
- **`category`** – Target muscle group or exercise type
- **`equipment`** – Required equipment (e.g., dumbbell, barbell, bodyweight)
- **`instructions_*`** – Multilingual instruction fields (e.g., `instructions_en`, `instructions_de`)
- **`image`** and **`gif_url`** – URLs to visual media assets

This schema allows you to perform complex relational queries, joins, and full-text searches across the entire dataset without parsing JSON in your application layer.

## Summary

- The **[`setup.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/setup.html)** file in the `hasaneyldrm/exercises-dataset` repository generates a complete MySQL import script containing `CREATE TABLE` and `INSERT` statements for all 1,324 exercises.
- The source data resides in **[`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json)**, with schema validation available in **[`data/exercises.schema.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.schema.json)**.
- Import the generated `.sql` file using the standard `mysql -u <username> -p < filename.sql` command.
- Verify success by checking that `SELECT COUNT(*) FROM exercises` returns **1324**.
- The resulting table includes columns for equipment, categories, multilingual instructions, and media URLs.

## Frequently Asked Questions

### What is the fastest way to import the exercises dataset into MySQL?

The fastest method is using the browser-based generator in **[`setup.html`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/setup.html)**. Open the file, select the MySQL tab, click **Generate .sql**, and load the resulting file with `mysql -u <username> -p < exercises_mysql.sql`. This approach handles schema creation and data insertion automatically without requiring manual JSON parsing or custom scripts.

### How many exercise records are included in the dataset?

The dataset contains **1,324** distinct exercise records. After importing, you can verify this count by running `SELECT COUNT(*) FROM exercises;` in your MySQL client. This number corresponds to the total entries in the source file [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json).

### What columns are created in the MySQL table?

The import script creates columns that map directly to the JSON schema, including `id`, `name`, `category`, `equipment`, `image`, `gif_url`, and multilingual instruction fields (prefixed with `instructions_`). The schema supports full-text search and relational queries across equipment types and muscle categories.

### Can I validate the JSON data before importing it into MySQL?

Yes. The repository includes **[`data/exercises.schema.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.schema.json)**, which provides a formal JSON Schema definition for all exercise objects. You can validate the data in [`data/exercises.json`](https://github.com/hasaneyldrm/exercises-dataset/blob/main/data/exercises.json) against this schema using any JSON Schema validator before running the SQL import to ensure data integrity and catch any structural anomalies.