To import an SQL file using the command line in MySQL, follow these steps:
- Open a terminal window and log in to MySQL as the root user:
mysql -u root -p
- Enter the password for the root user when prompted.
- Use the following command to create a new database:
CREATE DATABASE database_name;
- Use the following command to select the database:
USE database_name;
- Use the following command to import the SQL file:
SOURCE path/to/file.sql;
Replace database_name
with the name of the database you want to create and path/to/file.sql
with the path to the SQL file you want to import.
If the import was successful, you should see a message indicating that the import was completed.