1, into the MySQL directory under the Bin folder: 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 directly to the environment variable path of Windows)
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 allow you to enter the password into MySQL)
(If you export a single table, enter the table name after the database name)
3, will see the file News.sql automatically generated to the bin file
command-line Import Database
1, to move the imported. sql file to the bin file, this is a convenient path
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 (Enter the same after 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, enter: Mysql>use Target database name
As I entered the command line: Mysql>use news;
6, import file: Mysql>source import of the file name;
As I entered the command line: Mysql>source news.sql;
MySQL backups and restores are done using the mysqldump, MySQL, and source commands.
Backup and restore of MySQL under Linux
2.1 Backup
[Root@localhost ~]# cd/var/lib/mysql (access to MySQL library directory, adjust directory according to your MySQL installation situation)
[Root@localhost mysql]# mysqldump-u root-p voice>voice.sql, enter the password.
2.2 Restore
Law I:
[Root@localhost ~]# mysql-u root-p carriage return, enter password, enter MySQL console "mysql>", restore with 1.2.
Law II:
[Root@localhost ~]# cd/var/lib/mysql (access to MySQL library directory, adjust directory according to your MySQL installation situation)
[Root@localhost mysql]# mysql-u root-p voice<voice.sql, enter the password.