Loading data from a SQL file
A SQL file is usually generated with the mysqldump
command so that we can export from one database system and later import into a new one. The mysqldump
utility comes with MySQL. One file can hold data and definitions for multiple tables and schemas. Another source of the SQL file is when installing or upgrading third-party software. It is a file that contains all the changes needed to make the database ready for the new version.
Let's say you want to load the world.sql
file. First, create a database using the following command:
CREATE DATABASE world;
Ensure that you are using the world
database by writing the following command:
USE world;
Use the following query to load the world.sql
file:
source /path/to/world.sql
You will be able to access the content inside the world
database. Ensure that you have given the correct path of the world.sql
file (which is stored in your local system).
In order to access all the tables present...