Thursday 13 February 2014

Import MySQL database using SOURCE

Importing files to MySQL database using SOURCE.

Start MySQL console

Create database DATABASE_NAME;
Use DATABASE_NAME;
Source path/to/file.sql;

Here I have created a new database 'Example' and started using it.
Then using Source to import a file called world.sql.

create database Example;

use Example;

source /home/glen7/Documents/world.sql;



After show databases we can see that 'Example' has been imported.


Check for tables
Show tables;


Check schema of tables, City in this case.
describe City;



There are practice databases for you to download and use to practice on the MySQL website.

Sakila database and world database.


Other good resources for SQL are 



No comments:

Post a Comment