MeterSphere Database Backup and Restore

配置環境

# 数据库配置
## 是否使用外部 MySQL 数据库
MS_EXTERNAL_MYSQL=false
## MySQL 数据库地址,仅在使用外部数据库时修改
MS_MYSQL_HOST=mysql
## MySQL 数据库端口,仅在使用外部数据库时修改
MS_MYSQL_PORT=3306
## MySQL 数据库库名, 仅在使用外部数据库时修改
MS_MYSQL_DB=metersphere
## MySQL 数据库用户名
MS_MYSQL_USER=root
## MySQL 数据库密码
MS_MYSQL_PASSWORD=Password123@mysql

備份步驟

docker exec -u 0 -it mysql bash
mysqldump -u root -p metersphere > backup.sql
Enter password:Password123@mysql
exit
docker cp mysql:/backup.sql backup.sql

資料庫還原

docker cp backup.sql mysql:/backup.sql
docker exec -u 0 -it mysql bash
# mysql -u root -p
mysql > drop database metersphere;
mysql > create database metersphere;
mysql > exit
msctl status
docker logs [container-Name]
mysql -u root -p metersphere < backup.sql

結論

參考資料

--

--

NTUT CSIE | Biomedical Informatics Lab | github.com/stwater20 | sectools.tw

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store