Importing .sql Files from MySQL Workbench

MySQL Workbench provides a graphical interface to import .sql files easily.
Follow the steps below to restore your database using the Data Import Wizard.

Step 1: Open MySQL Workbench

On the Workbench home screen, click on the appropriate connection to your MySQL server.
If you haven’t created a connection yet:

  • Click + to add a new connection
  • Enter hostname, port, username, and password
  • Click Test Connection to verify
  • Save and open the connection

Step 2: Navigate to Data Import

Once connected:

  • Go to the top menu bar
  • Click Server > Data Import

This opens the Data Import Wizard, which guides you through the import process.

Step 3: Choose Import Method

In the Data Import screen:

  • Select Import from Self-Contained File
  • Browse and choose your .sql file (e.g., school_backup.sql)

The file should contain SQL statements generated by mysqldump or another export tool.

Step 4: Select Target Database

Choose the database where you want to import the data.

Step 5: Start the Import

Click Start Import at the bottom right of the wizard.
MySQL Workbench will execute the SQL statements from the file and restore your database.

Scheduled Backups Using Cron (Linux/macOS)

You can automate regular backups of your MySQL databases using the cron scheduler. This ensures that backups are created at fixed intervals without requiring manual execution.

Example: Daily Backup at 2 AM

0 2 * * * mysqldump -u root -p[yourpassword] school_db > /backups/school_db_$(date +%F).sql

The above cron job runs every day at 2:00 AM, creating a backup file with the current date appended to its name (e.g., school_db_2025-09-07.sql).

Security Note

Avoid placing your password directly in the cron job. Instead, use a ~/.my.cnf file to store your MySQL credentials securely.