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 5.5\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 lmapp-p lmapp-p 3308 > Lmapp.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)
MySQL Export database a table
Mysqldump-u user name-P database name Table name > exported file name
Mysqldump-u lmapp-p Lmapp users> test_users.sql (no semicolon at the end)
3, will see the file News.sql automatically generated to the bin file
When exporting, you encounter the above problem.
Workaround: Add a parameter-P 3308 (MySQL service port) to solve the problem.
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;
Note: Due to the size of the imported database and the different data structure, the time required for the import varies considerably. The database I imported is 123M and takes nearly 5 hours. During the thought of the machine downtime, carefully observe the command line interface found that the import is in the normal. After the successful import the interface is as follows:
Note: When importing a single data table, use a SQL statement similar to Lmapp Lm_area, source Lm_area.sql. The original data table can exist, and the imported datasheet overwrites the existing data table with the same name.
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.
Thank you for reading, I hope to help you, thank you for your support for this site!