deploy/docks/mysql-deploy-log.md

67 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# MySQL 容器部署日志
部署时间:2026-09-01
## 服务器
- IP:`47.112.207.185`(阿里云,Gitea 也在这台机器上,端口 3000)
- SSH:`ssh evanliu@47.112.207.185`
- SSH 密码:`@PRll1978`
Windows Git Bash 下免交互登录(无 sshpass 时):
```bash
mkdir -p /tmp/sshask && printf '#!/bin/sh\necho "@PRll1978"\n' > /tmp/sshask/pass.sh && chmod +x /tmp/sshask/pass.sh
export SSH_ASKPASS=/tmp/sshask/pass.sh SSH_ASKPASS_REQUIRE=force DISPLAY=:0
ssh -n evanliu@47.112.207.185 '<远程命令>'
```
## MySQL 容器
- 容器名:`mysql`,镜像 `mysql:8.4`(MySQL 8.4.11)
- 端口:`0.0.0.0:3306 -> 3306`
- 数据目录(bind mount):`/home/evanliu/mysql-data` -> `/var/lib/mysql`(2026-09-01 由命名卷 `mysql_data` 迁移,数据原样复制,账号密码不变)
- 重启策略:`unless-stopped`
启动命令(重建时用,数据目录已有数据,无需再传 root 密码):
```bash
docker run -d --name mysql --restart unless-stopped \
-p 3306:3306 -v /home/evanliu/mysql-data:/var/lib/mysql \
-e TZ=Asia/Shanghai \
mysql:8.4
```
注意:服务器直连 Docker Hub 超时,镜像通过加速器 `docker.1ms.run` 拉取后重打标签:
```bash
docker pull docker.1ms.run/library/mysql:8.4
docker tag docker.1ms.run/library/mysql:8.4 mysql:8.4
```
## 账号
| 账号 | 密码 | host | 权限 |
| --- | --- | --- | --- |
| root | `@PRll1978` | `%`(支持远程) | 全部 |
| evanliu | `@PRll1978` | `%`(支持远程) | `ALL PRIVILEGES ON *.*` + `WITH GRANT OPTION`,等同 root |
创建 evanliu 的 SQL:
```sql
CREATE USER IF NOT EXISTS "evanliu"@"%" IDENTIFIED BY "@PRll1978";
GRANT ALL PRIVILEGES ON *.* TO "evanliu"@"%" WITH GRANT OPTION;
FLUSH PRIVILEGES;
```
远程连接:
```bash
mysql -h 47.112.207.185 -P 3306 -u evanliu -p
# 密码: @PRll1978
```
## 风险提示
- root 和 evanliu 均允许任意主机连接,公网暴露 3306 风险较高,建议阿里云安全组只放行需要的来源 IP。