---
# System prepended metadata

title: backup SQL with schema & data & user account/permission
tags: [MIS]

---

---
tags: MIS
---
# backup SQL with schema & data & user account/permission

### backup schama only
**If you encounter the foriegn key problem ,you can create the schema first and then insert the data**

```
#全部資料庫裡的schema都倒出來
mysqldump -u <your_account> -p <your_password> -d --all_databases -B > <your_schema_backup_filename>.sql

#特定database 的 schema 倒出來
mysqldump -u <your_account> -p <your_password> -d <your_specific_database_name> -B > <your_schema_backup_filename>.sql
```



### backup data only
`mysqldump -u <your_account> -p <your_password> --no-create-info --all_databases > <your_schema_backup_filename>.sql`

### backup user account/permission
`mysqldump -u root -p mysql user > <your_user_backup_filename>.sql`