You can import an exported SQL file using the CLI (command line) in the following steps:
- Open terminal, and login to MySQL CLI utility:
mysql -u <username> -p
Replace
<username>with your MySQL username. You will be prompted to enter your MySQL password after executing this command. - Once you're logged in, specify the database you want to use:
use <database_name>;
Replace
<database_name>with the name of the database where you want to import the SQL file. - Specify the SQL file to import using the
sourcecommand:SOURCE data.sql;
Replace "
data.sql" with the actual name of the SQL file you want to import.
Alternatively, you can also use the following one-liner command to achieve the same:
mysql -u <username> -p <database_name> < data.sql
This command will log you into the MySQL CLI utility and import the "data.sql" file into the specified database.