Site icon TestingDocs.com

MySQL Database Import using SQL file

MySQL Database Import using SQL file

In this tutorial, we will learn MySQL import using SQL statement file(*.sql file extension). SQL statement file is a script file that contains SQL commands and queries that can be executed at the MySQL command shell.

New data can be imported into a database using a SQL statement file that contains the information needed to create tables, insert data, etc.

For example, to import the world database SQL file, we could use the following statement:

\> mysql -u root-p world < world.sql

This will prompt for the root password.

SOURCE command

We can also use the SOURCE command from the mysql client’s interactive shell. MySQL shell-level client commands do not require a semi-colon(;) at the end of the statement.

mysql> SOURCE /path/to/file

Alternatively, the SOURCE can be replaced with \.

mysql> \. <path_to_SQL_filename>

For example, on the Windows operating system import the database from the world.sql file located at C:/world.sql location.

SOURCE C:/files/world.sql

The SQL statements in the script are sent to the MySQL server and executed. The server sends the message for each statement. The command-line MySQL client echoes the server messages to the computer screen.

We can also import from a data file using the LOAD DATA INFILE statement.

MySQLImport Utility

https://www.testingdocs.com/import-data-with-mysqlimport-utility/

MySQL Tutorials

MySQL Tutorials on this website:

For more information on MySQL Database:

Exit mobile version