What is the command to import a database in MySQL?
The command to import a database in MySQL is to use the mysql command-line tool to execute an SQL script file. Below is the basic command format for importing a database in the terminal:
mysql -u username -p database_name < file.sql
- – Username: Specifies the username to connect to MySQL.
- – Password prompt: Enter the user’s password before importing can be done.
- Name of the database that data will be imported into.
- file.sql is used to import data from a specified SQL file.
Please ensure that the current user has sufficient privileges to import the database when executing the above command. If the SQL file contains statements to create a database, appropriate permissions are also needed to create the database.