First, log in to MySQL as root or another user with sufficient privileges to create new databases:
mysql -u root -p
Next, create a new database with the following command. In this example, the new database is called new_database:
CREATE DATABASE new_database;
Then exit the MySQL shell by pressing CTRL+D
. From the normal command line, you can import the dump file with the following command:
mysql -u username -p new_database < dump.sql
username is the username you can log in to the database with
new_database is the name of the freshly created database
dump.sql is the data dump file to be imported, located in the current directory
If the command runs successfully, it won’t produce any
output. If any errors occur during the process, mysql will print them to
the terminal instead.
To check if the import was successful, log in to the MySQL shell and double check the database. Select the new database with USE new_database
and then use SHOW TABLES;
Posted by: admin
2023-10-25 14:13:00