|
Use the MySQL command line can be achieved on the database backup and recovery, here to introduce you to use the MySQL command detailed process steps to achieve the function of the line for your reference.
MySQL command line to export the database:
1, bin files into the MySQL directory folder: cd MySQL bin directory to the folder
As I entered the command line: cd C: \ Program Files \ MySQL \ MySQL Server 4.1 \ bin
(Or directly add the directory path of the windows environment variable)
2, export the database: mysqldump -u username -p database name> exported file name
As I entered the command line: mysqldump -u root -p news> news.sql (after entering into the MySQL will let you enter the password)
(If you export a single table, then you can enter the name of the table after the database name)
3, you will see the next file is automatically generated to bin file news.sql
MySQL command line into the database:
1, .sql files will be moved to the bin file import under this path more convenient
2, with the above derived in step 1
3, enter MySQL: mysql -u username -p
As I entered the command line: mysql -u root -p (enter the same post will let you enter the MySQL password)
4, you have to build a new database in MySQL-Front, the case is an empty database, such as the new target database called the news
5, enter: mysql> use the target database name
As I entered the command line: mysql> use news;
6, import file: mysql> source filename to import;
As I entered the command line: mysql> source news.sql;
MySQL backup and restore, are using mysqldump, mysql and source commands to complete.
1.Win32 under MySQL backup and restore
Backup 1.1
Start Menu | Run | cmd | use "cd \ Program Files \ MySQL \ MySQL Server 5.0 \ bin" command to enter the bin folder | use "mysqldump -u username -p databasename> exportfilename" export the database to a file, such as mysqldump -u root -p voice> voice.sql, then enter the password to start the export.
Restore 1.2
Into the MySQL Command Line Client, enter the password, go to "mysql>", enter the command "show databases;", Enter, see what the database; to build your database to be restored, enter "create database voice;", carriage return ; switches to the newly created database, enter "use voice;", enter; import data, enter "source voice.sql;", the transport, import, appears "mysql>" prompt again and no error that is successful restore.
2.Linux under MySQL backup and restore
Backup 2.1
[Root @ localhost ~] # cd / var / lib / mysql (into the MySQL database directory, according to their own situation to adjust MySQL installation directory)
[Root @ localhost mysql] # mysqldump -u root -p voice> voice.sql, enter the password.
Restore 2.2
Method One:
[Root @ localhost ~] # mysql -u root -p Enter, enter a password, enter the MySQL console "mysql>", with 1.2 reduction.
Act II:
[Root @ localhost ~] # cd / var / lib / mysql (into the MySQL database directory, according to their own situation to adjust MySQL installation directory)
[Root @ localhost mysql] # mysql -u root -p voice < voice.sql, enter the password. |
|
|
|