Home >Backend Development >PHP Tutorial >PHP uses the command line to export and import MySQL database, command line mysql_PHP tutorial
Command line to export database:
1. Enter the bin folder in the MySQL directory: cd to the bin folder in MySQL
For example, the command line I entered: cd C:Program FilesMySQLMySQL Server 4.1bin
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 into the bin file
Command line import database:
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
3, enter MySQL: mysql -u username -p
as I entered Command line: mysql -u root -p (After entering the same command, you will be asked to enter the ySQL password)
4. Create the 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;