MySQL 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 1.win32
1.1 Backup
Start Menu | Run | cmd | Access the Bin folder using the "CD \program Files\mysql\mysql Server 5.0\bin" command | Use the 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 exporting.
1.2 Restore
into the MySQL command line Client, enter the password, enter the "mysql>", enter the command "show databases;", carriage return, see what some database; Create the database you want to restore, enter "Create db Voice; ", carriage return; switch to the newly established database, type" use voice; ", enter the data, enter" source voice.sql; ", carriage return, start the import, reappear" mysql> "and restore success without prompting for an error.
Backup and restore of MySQL under 2.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.
MySQL command line export database:
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