如何轻松地从 MySQL 迁移到 PostgreSQL?

发布于 2024-07-15 21:56:48 字数 388 浏览 3 评论 0原文

我想在现有的 MySQL 数据库(大约 40 个表,400 MB 数据)变得更大之前将其迁移到 Postgres。 我搜索了网络并尝试了一些迁移脚本(其中一些可以在此处找到)。 它们都不能无缝工作——如果只是一些我必须手动修复的小故障,那不会是问题,但生成的转储看起来根本不像有效的 PostgreSQL。

是否有人在不使用整个工作日的情况下成功迁移生产表 - 对于该问题有一个简单的解决方案吗?

注:我也会考虑商业产品(只要定价仍然可行)。

I'd like to migrate an existing MySQL database (around 40tables, 400mb data) to Postgres before it gets bigger. I searched the web and tried some migration-scripts (some of them can be found here). None of them works seamlessly - if it would be just a few glitches I had to fix manually, it wouldn't be a problem, but the resulting dumps don't look like valid PostgreSQL at all.

Did anybody succeed in migrating a production table without using a full workday - is there an easy solution to that problem?

Note: I also would consider commercial products (as long as pricing is still feasible).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滴情不沾 2024-07-22 21:56:48

尽管 SQL 是一个标准,但如果每个服务器软件都没有实现扩展,它的功能就不够完整。 从 MySQL 到 PostgreSQL 的转换并不简单,除非您的架构很简单。 自动翻译脚本只能帮助您到此为止。

最好的方法是手动翻译模式,然后为数据本身编写自己的传输脚本。 您还应该编写验证脚本以确保模式和数据正确传输。

这不是一个逃避的答案。 如果您的数据库对于迁移来说足够重要,那么您自己花一些时间也很重要。 最后,您花在解决怪异和微妙混乱上的时间至少与自动迁移脚本所导致的时间一样多,就像您自己迁移数据的时间一样。 但如果你自己动手,你就有机会利用 PostgreSQL 中 MySQL 中没有的功能,并且有机会做出只有有机会做第二次某事才能实现的各种改进。

硬着头皮去做吧。

In spite of SQL being a standard, it's not full featured enough to do without each server software implementing extensions. The translation from MySQL to PostgreSQL is not simple, unless your schema is trivial. Automated translation scripts will only get you so far.

The very best approach would be to hand translate the schema, and then write your own transfer scripts for the data itself. You should also write verification scripts to make sure the schema and data come over correctly.

This isn't a cop-out answer. If your database is important enough to migrate then it's important enough to spend some time on yourself. In the end you would spend at least as much time figuring out the quirks and subtle messes than an automated migration script would cause as in the time to migrate the data yourself. But doing it yourself you have the chance to take advantage of features in PostgreSQL that aren't present in MySQL, as well as the chance to make the kinds of improvements that only come from having the chance to do something a second time.

Bite the bullet and do it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文