Home >Backend Development >PHP Tutorial >PHP uses the command line to export and import MySQL database, command line mysql_PHP tutorial

PHP uses the command line to export and import MySQL database, command line mysql_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:44:411127browse

php Use command line to export and import MySQL database, command line mysql

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;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1048741.htmlTechArticlephp Use command line to export and import MySQL database, command line mysql command line to export database: 1. Enter the MySQL directory The bin folder: cd MySQL to the directory of the bin folder as I entered...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn