文章

外接托管 MySQL 数据库平台 Railway

为我的 Waline 评论系统寻找外接的 MySQL 云提供商。

为了方便访客留言,我为我的吹牛逼博客部署了 Waline 评论系统。这个系统需要接入一个数据库,MongoDB、MySQL、Postgres 都行。我想了想,如果想要长久保存,还是生态最丰富的 MySQL 最靠谱。

我不想把 MySQL 运行在我的 VPS 上,因为我的 VPS 经常会搞一些实验性质的东西把服务器搞炸。

2025年了,于是我直接问我们的 GPT 老师,外接 MySQL 托管哪家强:

1
2
I have an application that needs a MySQL database. I dont want to set it up on my own server but use a cloud provider's. Do you have any suggestions?
The data volume and traffic volume is low but I hope it can persist long with low price while I can backup the data and transfer it at any time

答曰:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Absolutely — for low-traffic, low-volume MySQL databases with persistent storage, backups, and easy migration, there are several good cloud options. Since you're optimizing for **low cost**, **longevity**, and **portability**, here are some curated suggestions:

---

### 🔹 1. **PlanetScale** *(Highly recommended for your use case)*
- **Pricing**: Free tier available with generous limits.
- **Key Features**:
  - MySQL-compatible (built on Vitess, used by YouTube).
  - Serverless scaling.
  - Non-blocking schema changes.
  - Automatic daily backups (paid tiers have longer retention).
  - CLI and web-based data export.
- **Best for**: Projects needing long-term free hosting and easy backups.

📌 **Notes**:
- Doesn't allow direct access to `mysqldump` (uses its own export tools).
- Slightly different from traditional MySQL in some low-level admin operations.

---

### 🔹 2. **Railway**
- **Pricing**: Free tier includes 500MB of storage, with paid plans starting low.
- **Key Features**:
  - Easy MySQL deployment with backup/export options.
  - Integration with Git-based workflows.
  - Nice for quick prototyping and persistent development.
- **Best for**: Simple apps needing database + backend hosted together.

---

### 🔹 3. **Render**
- **Pricing**: $7/month for Managed MySQL.
- **Key Features**:
  - Daily backups, automatic scaling.
  - Simple UI for database access.
- **Best for**: More traditional MySQL feel, small production apps.

---

### 🔹 4. **Google Cloud SQL / Amazon RDS / Azure Database for MySQL**
- **Pricing**: Paid from the start (~$15+/month for the lowest setup).
- **Key Features**:
  - Fully managed, high availability, easy snapshot backup and export.
- **Best for**: Production-grade reliability, enterprise-level features.
- **Not recommended** if you're trying to keep it super cheap.

---

### 🔹 5. **DigitalOcean Managed Databases**
- **Pricing**: Starts from $15/month, but frequent discounts for new users.
- **Key Features**:
  - Automatic backups, metrics, scaling.
  - Easy migration using `mysqldump` or `pg_dump`.
- **Best for**: If you may later scale up without changing platforms.

---

### ✅ Summary Recommendation:

| Provider       | Free Tier | Backup/Export | Best For                            |
|----------------|-----------|----------------|-------------------------------------|
| **PlanetScale** | ✅         | ✅ (with CLI)   | Long-term, low-traffic apps         |
| **Railway**     | ✅         | ✅              | Quick setups with portability       |
| **Render**      | ❌         | ✅              | More control with affordable price  |
| **GCP/AWS/Azure**| ❌        | ✅              | Production, but more costly         |
| **DigitalOcean**| ❌ (trials) | ✅             | Budget production hosting           |

---

Let me know your preferred tech stack or budget limit and I can help you choose/setup one of these platforms with actual steps.

PlanetScale 已经不给白嫖了,于是我去查 Railway。Railway 价格还是可以的,基本款5刀一个月,而且给5刀的免费试用。

用了一下,发现这个 Railway 其实就是拖控件开 Docker 构建数据流。理论上可以把自己的大多数容器化服务都托管到上面。

image-20250417235056668

部署过程中遇到了一个问题。Waline 不支持8以上的 MySQL,于是我需要把 Railway 默认提供的 MySQL 版本改掉。但是当我把 Docker image 的版本从9改到5.7再重新部署,Railway 一直在报错。查看错误日志,原来是因为绑定的 Data Volume 依然保存了创建时默认的9版本的内容。所以需要先改 image 版本,再手动删掉那个默认提供的 Volume ,再绑一个新的空 Volume 上去。

为了这个我折腾了半个多小时。这个网站的设计师一定觉得自己聪明坏了,拖控件编程好帅好爽好方便一定能大卖吧……然而这样的反直觉的操作流程还不如用命令行操作 Docker 时得到的提示直接——至少我可以直接 docker compose down -v,连带着 container 及其挂载的持久化卷一同删除。总觉得搞这种创业项目费力不讨好,高不成低不就,不知道什么样的用户会依赖这样的服务。

不管怎么说,这家还算价格公道,暂且先用着了。以后可以考虑把更多 VPS 上的东西用这家部署。

本文由作者按照 CC BY 4.0 进行授权