## 服务器登陆账户密码
==================================================================
aaPanel Internet Address: https://3.1.203.22:30745/c7f96c0b
aaPanel Internal Address: https://172.31.21.167:30745/c7f96c0b
username: 9mgygf2h
password: dZ8jdADwTZ

# 宝塔
地址： https://www.aapanel.com/

## 安装国际版
```bash
sudo su
URL=https://www.aapanel.com/script/install_7.0_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O install_7.0_en.sh "$URL";fi;bash install_7.0_en.sh aapanel
```


# 数据库
所有功能基于 root 账户下生成
## docker -mysql9.0基础信息
| key                    | value                                   |     |
| ---------------------- | --------------------------------------- | --- |
| name                   | mysql_PfsC                              |     |
| app name               | MySQL                                   |     |
| app type               | Database                                |     |
| Database root password | F8D4cXMPt3jGd7LL                        |     |
| mysql port             | 13306                                   |     |
| app directory          | /www/dk_project/dk_app/mysql/mysql_PfsC |     |
| Cpu core limit         | No limit                                |     |
| memory limit           | No limit                                |     |
| installed log          | /tmp/mysql_PfsC.log                     |     |
| Allow external access  | yes                                     |     |

## 新建数据库
在 https://3.1.203.22:30745/database/mysql 中新建；

![[Pasted image 20250514163944.png]]

步骤如下：

1. **创建用户 `'va'@'%'`（如果还没有）**

sql

`CREATE USER 'va'@'%' IDENTIFIED BY 'your_password';`

> 请将 `your_password` 替换为你想设置的密码。

2. **授权**
```sql
GRANT ALL PRIVILEGES ON va.* TO 'va'@'%';

FLUSH PRIVILEGES;
```

## 备份
在 https://3.1.203.22:30745/crontab/task 页面配置了定时备份脚本，每日凌晨03:01执行, 以下是脚本执行代码:
```
#!/bin/bash

# 配置参数
CONTAINER_ID="fe8fde9961b2"
DB_USER="root"
DB_PASS="F8D4cXMPt3jGd7LL"
DB_NAMES=("va_sandbox" "va")  # 这里写上你要备份的所有数据库名
BACKUP_DIR="/www/dk_project/dk_app/mysql/mysql_PfsC/data/backup"

# 获取当前时间
NOW=$(date +"%Y-%m-%d_%H-%M-%S")

for DB_NAME in "${DB_NAMES[@]}"
do
    FILENAME="${DB_NAME}_${NOW}_mysql_data.sql.gz"
    BACKUP_PATH="${BACKUP_DIR}/${FILENAME}"

    # 备份命令
    docker exec ${CONTAINER_ID} mysqldump -u${DB_USER} -p${DB_PASS} ${DB_NAME} | gzip > "${BACKUP_PATH}"
done
```

导出指定的数据库：
```bash
sudo su
docker exec fe8fde9961b2 mysqldump -uva_sandbox -pCSkCada2h87YYZRt va_sandbox | gzip > va_sandbox_2025-05-14.sql.gz
```

## 恢复

恢复 va_sandbox 数据库：
```bash
sudo su
gunzip -c /www/dk_project/dk_app/mysql/mysql_PfsC/data/va_sandbox_2025-05-14_09-30-03_mysql_data.sql.gz | docker exec -i fe8fde9961b2 mysql -uva_sandbox -pCSkCada2h87YYZRt va_sandbox
```

va_test_2025-05-15_09-30-02_mysql_data.sql



gunzip -c /www/dk_project/dk_app/mysql/mysql_PfsC/data/va_test_2025-05-15_09-30-02_mysql_data.sql.gz | docker exec -i fe8fde9961b2 mysql -uva_test -pPGsCkBBc7XBxtrhW va_test

恢复 va 数据库：
```bash
sudo su
gunzip -c /www/dk_project/dk_app/mysql/mysql_PfsC/data/va_2025-05-14_09-30-02_mysql_data.sql.gz | docker exec -i fe8fde9961b2 mysql -uva -pFHZ36dP527GacTty va
```

基础知识：
https://chatnio.net/share/ee529f7307dd407ceaefdd3228113f43


docker exec -it fe8fde9961b2 /bin/bash
