Backup and restore of MySQL database and table

Source: Internet
Author: User

Backup

Export Database all table structure

mysqldump -uroot -ppassword -d dbname > db.sql

Export a table structure for a database

mysqldump -uroot -ppassword -d dbname tablename > db.sql

Export database all table structure and data

mysqldump -uroot -ppassword dbname > db.sql

Export a table structure and data for a database

mysqldump -uroot -ppassword dbname tablename > db.sql

Export part of the data

--where="条件"mysqldump -uroot -ppassword dbname tablename -w "条件" > db.sql

-W or –where, the condition must be surrounded by double quotes, single quotation mark not.

Note
Exporting data does not require-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 has no lock tables permissions.

Solutions
(1) Granting permission to the user lock tables
(2) Add --skip-lock-tables , as

mysqldump -uroot -ppassword dbname --skip-lock-tables > db.sql
Import
source xxx.sql

(1) A semicolon cannot be followed by a statement;
(2) User must have insert and other permissions

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Backup and restore of MySQL database and table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.