I will give you an example to introduce how to use the command line to export and import MySQL into the database
1. Export database from command line
1. Enter the bin folder in the MySQL directory: cd to the directory of the bin folder in MySQL
For example: cd C:Program FilesMySQLMySQL Server 4.1bin
(Or directly add the directory to the Windows environment variable path)
2. Export database: mysqldump -u username -p database name > exported file name
For example, the command line I entered: mysqldump -u root -p news > news.sql (After entering, you will be asked to enter the password to enter MySQL)
(If you export a single table, just enter the table name after the database name)
3. You will see that the file news.sql is automatically generated under the bin file
2. Import the database from the command line:
1. Move the .sql file to be imported to the bin file. This path is more convenient
2. Same as step 1 of the above export:
Enter the bin folder in the MySQL directory: cd to the directory of the bin folder in MySQL
For example: cd C:Program FilesMySQLMySQL Server 4.1bin
(Or directly add the directory to the Windows environment variable path)
3. Enter MySQL: mysql -u username -p
For example, the command line I entered: mysql -u root -p (after entering the same, you will be asked to enter the MySQL password)
4. Create a new database you want to build in MySQL-Front. At this time, it is an empty database. For example, create a new target database named news
5. Enter: mysql>use target database name
For example, the command line I entered: mysql>use news;
6. Import file: mysql>source imported file name;
For example, the command line I entered: mysql>source news.sql;
The above is the entire content of this article. I hope it will be helpful to everyone’s study and I hope you will support me a lot.