Mysql Command (database backup and recovery), mysql Database Backup
Local:
1. Enter the bin folder in the MySQL Directory: e: Press ENTER;
E: \> cd mysql \ bin? Enter
2. Export Database: mysqldump-u username-p Database Name> exported file name
Example:
Mysqldump-uroot-p abc> abc. SQL
(Export the database abc to the abc. SQL file)
When prompted to enter the password, enter the password of the database user name (if you export a single table, enter the table name after the database name)
If a locktable error is prompted, add a space after mysqldump-uroot-p abc.-- Skip-lock-tables
3. Will the file news. SQL be automatically generated under the binfile?
MySQL command line import database:
1. The. SQL file to be imported is moved to the binfile, which is convenient.
2. Step 1 of the above-mentioned export
3. Enter MySQL: mysql-u username-p
For example, the command line I entered is mysql-u root-p ?? (After entering the same password, you will be asked to enter the MySQL password)
4. Create the database you want to create in MySQL-Front. An empty database is used, for example, create a target database named "news ".
5. Enter the mysql> use target database name.
For example, the command line I entered is mysql> use news;
6. Import file: the file name imported from mysql> source;
For example, the command line I entered is mysql> source news. SQL;
MySQL backup and restoration are completed using mysqldump, mysql, and source commands.
1. MySQL backup and restoration under Win32
1.1 backup
Start Menu | run | cmd | use the "cd \ Program Files \ MySQL Server 5.0 \ bin" command to enter the bin folder | use "mysqldump? -U username-p databasename> exportfilename ": export the database to a file, for example, mysqldump-u root-p voice> voice. SQL. Then enter the password to start exporting.
?
1.2 restore
Enter the MySQL Command Line Client, enter the password, go to "mysql>", enter the Command "show databases;", Press enter to see what databases are there, and create the database you want to restore, enter "create database voice;", Press ENTER; switch to the database you just created, enter "use voice;", Press ENTER; import data, and enter "source voice. SQL; ", Press enter to start importing, and" mysql> "is displayed again. If no error is returned, the restoration is successful.
?
2. MySQL backup and restoration in Linux
2.1 backup
[Root @ localhost ~] # Cd/var/lib/mysql (go to the MySQL database directory and adjust the directory based on your MySQL installation)