1. Open a terminal window on your Linux system.

  2. Log in to MySQL using the following command. You will need to provide the MySQL root or a user with appropriate permissions and the password when prompted.

mysql -u your_username -p

Replace your_username with your MySQL username.

  1. Once you’re logged in, you can select the database where you want to import the SQL file. For example:

USE your_database;

Replace your_database with the name of the database you want to use.

  1. Now, you can import the SQL file using the source command. The basic syntax is as follows:

source /path/to/yourfile.sql;

Replace /path/to/yourfile.sql with the actual path to your SQL file.

  1. MySQL will execute the SQL commands from the file, and you should see the output on the terminal. When the import is finished, you’ll be returned to the MySQL prompt.

That’s it! You’ve successfully imported an SQL file into your MySQL database using the Linux terminal.