Backup and restoration of MySQL Databases and tables, and backup of mysql Databases
Backup
Export all database table Structures
mysqldump -uroot -ppassword -d dbname > db.sql
Export a table structure in the database
mysqldump -uroot -ppassword -d dbname tablename > db.sql
Export all database table structures and Data
mysqldump -uroot -ppassword dbname > db.sql
Export the structure and data of a table in the database
mysqldump -uroot -ppassword dbname tablename > db.sql
Export some data
-- Where = "condition" mysqldump-uroot-ppassword dbname tablename-w "condition"> db. SQL
-W or-where must be enclosed by double quotation marks.
Note:
Exporting data is not required-d
The following error may occur:
Mysqldump: Got error 1044: Access denied for use 'zndw' @ 'localhost' to database 'scilibrary 'when doing LOCK TABLES
This error occurs because the user does notlock tables
Permission.
Solution
(1) Assign the userlock tables
Permission
(2) Add--skip-lock-tables
, Such
mysqldump -uroot -ppassword dbname --skip-lock-tables > db.sql
Import
source xxx.sql
(1) The statement cannot be followed by a semicolon;
(2) The user must have insert and other permissions.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.