With the MySQL command line, you can make a backup of the database and restore, the following is a detailed method for you to use the MySQL command line to implement the function of the steps for your reference.
MySQL command line export database:
1. Go to the Bin folder in the MySQL directory: cd MySQL to the Bin folder directory
As I entered the command line: CD C:\Program files\mysql\mysql Server 4.1\bin
(or add the directory to the Windows environment variable path directly)
2, Export database: Mysqldump-u user name-p database name > exported file name
As I entered the command line: Mysqldump-u root-p News > News.sql (input will let you enter the password into MySQL)
(If you export a single table, enter the table name after the database name)
3, you will see the file News.sql automatically generated into the bin file
MySQL command line Import Database:
1, move the. sql file to be imported into the bin file, such a path is more convenient
2, the 1th step with the above export
3, enter mysql:mysql-u user name-P
As I entered the command line: mysql-u root-p (Input the same will let you enter the MySQL password)
4, create the database you want to build in Mysql-front, this is an empty database, such as a new target database named News
5, Input: Mysql>use target database name
As I entered the command line: Mysql>use news;
6, import file: mysql>source import filename;
As I entered the command line: Mysql>source news.sql;
MySQL backup and restore is done using the mysqldump, MySQL, and source commands.
Backup and restore of MySQL under 1.win32
1.1 Backup
Start Menu | Run | cmd | Enter the Bin folder with the "CD \program Files\mysql\mysql Server 5.0\bin" command | Use "Mysqldump-u user name-p databasename >exportfilename" to export the database to a file, such as Mysqldump-u root-p voice>voice.sql, and then enter the password to start the export.
1.2 Restore
Enter MySQL command line Client, enter the password, enter the "mysql>", enter the command "show databases;", enter to see what database; Create the database you want to restore, enter the Voice; ", enter; switch to the newly created database, enter" use voice; ", carriage return, import data, enter" source voice.sql; ", carriage return, start import," mysql> "again, and the restore succeeds without prompting the error.
Backup and restore of MySQL under 2.Linux
2.1 Backup
[[email protected] ~]# cd/var/lib/mysql (go to MySQL library directory, adjust the directory according to your MySQL installation situation)
[[email protected] mysql]# mysqldump-u root-p voice>voice.sql, enter the password.
2.2 Restore
Law One:
[[email protected] ~]# mysql-u root-p return, enter the password, enter the MySQL console "mysql>", with 1.2 restore.
Law II:
[[email protected] ~]# cd/var/lib/mysql (go to MySQL library directory, adjust the directory according to your MySQL installation situation)
[[email protected] mysql]# mysql-u root-p voice<voice.sql, enter the password.
This article is from "Playing Linux ... Do operation and maintenance ... Cluster "blog, be sure to keep this provenance http://scottlinn.blog.51cto.com/829656/1695884
Backing up and recovering databases using the MySQL command line