This tutorial explains how to save or export a database in a .sql file using HeidiSQL software.
The French version of this publication : Enregistrer une base de données MySQL dans un fichier .sql avec HeidiSQL
A .sql file is a text file containing instructions and queries written in Structured Query Language (SQL).
HeidiSQL is free, open-source software for managing MySQL, MariaDB, SQLite and other databases. It enables users to connect to a database and perform various management tasks, such as creating tables, inserting data, modifying table structures, executing SQL queries, etc.
To download HeidiSQL, visit the official website https://www.heidisql.com.
If you have installed Laragon as your development environment, you will benefit from the integration of HeidiSQL among the tools available in its suite. To open HeidiSQL from the Laragon window, simply click on the Database button.
Once HeidiSQL is open, you'll be greeted by the Session Manager window, which lets you connect to a database or database server. On the left, you'll find registered connections, while the Settings tab on the right lets you specify database connection information.
The screenshot above shows the connection information for a MySQL database with the default settings: host=127.0.0.1, user=root and port=3306. Pressing the Open button takes you to the HeidiSQL database management interface.
To export a database to a SQL file, right-click on the database name on the left-hand side of the interface, then select Export database to SQL.
This opens the Table Tools window. On the left, select the database and/or tables to be exported. Then, in the SQL Export tab on the right, choose your export parameters.
In the image above, the choices are as follows:
- "Create" for "Database" to create the database if it doesn't exist
- "Create" for "Table(s)" to create tables.
- "INSERT" for "Data" to insert table data.
- "Single .sql file" for "Destination" to specify export to a .sql file.
- "C:\Users\Wilo Ahadi\Desktop\akilischool_db.sql" for "File name" to specify the file to export the data to.
Finally, press Export to save your database to the specified file. This .sql file will contain the SQL instructions needed to recreate your database.
Take care 😎