RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Jun 9, 2021

How to Use the Source Command in MySQL

There are instances when you have data in SQL files that need to be uploaded to a database. MySQL has a source command that can help you achieve this very goal. This method works well with large SQL files as well.

The steps below illustrate how to upload SQL files to a database using MySQL.

Note: This article assumes that the SQL files is named sqlFile.sql. In the steps below, simply change this file name to the name of your own SQL file.

Step 1: Connecting to the mysql database:

[root@dev]# mysql -S /opt/mysql//mysql.sock -u -p 

Step 2: Choose the database in which you want to perform this operation:

[root@dev]# use 

Step 3: Using the source command. Assuming that the sqlFile.sql is present in the current folder, execute the following command:

[root@dev]# source sqlFile.sql;
MS Sridhar
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date