To import an SQL file into a MySQL database server, you can use the mysql
command-line client with the -u
option to specify the user name, the -p
option to specify a password (if necessary), and the -D
option to specify the database where the SQL file will be imported. For example, if the SQL file is named data.sql
and you want to import it into a database named mydatabase
, you can use the following command:
mysql -u username -p mydatabase < data.sql
After running this command, the MySQL client will prompt you for the password for the username
user. Once you enter the password, the data.sql
file will be imported into the mydatabase
database.
Alternatively, you can use the mysql
command with the -h
option to specify the hostname or IP address of the MySQL server, and the -P
option to specify the port number where the MySQL server is listening. For example:
mysql -u username -p -h mysqlserver.example.com -P 3306 mydatabase < data.sql
This command will import the data.sql
file into the mydatabase
database on the MySQL server located at mysqlserver.example.com
on port 3306
.
Note: You may need to adjust the MySQL client options and the database name in the command above to match your specific configuration.