TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL Import using SQL file

Overview

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>

MySQL Source Command

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:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL DROP TABLE Statement› MySQL SELECT DISTINCT clause

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com