在数据库之间移动表

发布于 2024-09-26 17:12:33 字数 600 浏览 3 评论 0原文

为了进行秋季清理,我在 MySQL 数据库(不同的硬件)之间移动 25 个表。这不是整个数据库,只是数百个表中的 25 个...这些表并不真正属于那里,出于 NDA 原因,我不会详细说明原因。

现在,这将破坏大量代码和 SQL 查询。

这样做的最佳方法是什么?

  1. 一次性把它们全部移过来。

  2. 将它们一一一一地移动

——

一次性将它们全部移动,这感觉很好。可能是我错过了一些中断和损坏的代码,但将它们作为一个块移动要快得多,推送代码所花费的时间也更少。

将它们一一移动是一种很好的方式,大的东西损坏的可能性较小,但更多的时间将花在微观管理工作、冗余工作和部署上。

我可以暂时镜像两个数据库之间的表吗?也许是联合表?

--

其他信息:共有 25 个表,所有表的内容都相互关联。

我不能一次关闭数据库几个小时,大约 5 分钟的停机时间是可以接受的。

--

移动所有这些数据并使代码、sql 和我保持良好状态的最佳方法是什么?

我可以联合这些表作为将表复制到新数据库的一种方式吗?

-丹尼尔

For a bit fall cleaning, I am moving 25 tables between MySQL databases (different pieces of hardware). This is not the WHOLE database, just 25 tables out of a few hundred... These tables don't really belong in there, I won't go into why for NDA reasons.

Now, this is going to break a lot of code and sql queries.

What is the best way to go about doing this?

  1. Move them all over at once.

  2. Move them over 1 by 1

--

Moving them over all at once, is kind of nice. Might be some outages and broken code that I missed, but moving them as a block is much faster, less time spent in pushing code out.

Moving them over one by one is kind of nice, less chance of big stuff breaking, but a LOT more time will be spent micromanaging the work, redundant work, and deploying.

Is it possible for me to mirror the tables between two databases for a while? A federated table perhaps?

--

Misc info: There are 25 tables are all related by content to each other.

I cannot shutdown the databases for hours at a time, about 5 minutes of downtime would be acceptable.

--

What is the best way to go about moving all of this data and keeping the code, sql, and me in great shape?

Could I federate the tables as a way of replicating the tables to a new database?

-daniel

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

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

发布评论

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

评论(3

丢了幸福的猪 2024-10-03 17:12:33

看来一次将它们移动一个是可行的方法。这样你就会遇到一堆简单的小问题,而不是一个大的难题。我希望您的系统经过大量的自动化测试,以确保所有这些改组不会破坏任何东西。

另一件事:你谈到关闭数据库。如果您在开发环境中进行更改,并且仅在确定一切正常时才使更改生效,那么为什么需要在生产中停机?我希望您不要在没有首先在开发中进行这些更改的情况下考虑在生产中进行这些更改。

It seems like moving them over one at a time would be the way to go. That way you have a bunch of easy little problems instead of a big hard problem. I hope you have your system under a lot of automated tests to make sure all this shuffling doesn't break anything.

Another thing: you talk about shutting down the database. If you're making the changes in a development environment and only making the changes live when you're sure everything works, why would you need to have any downtime in production? I hope you're not thinking about making these changes in production without doing it in development first.

2024-10-03 17:12:33

你可以使用SQLYog(mysql前端)来做到这一点。

Meny选项是Powertools ->数据库同步向导

您必须能够远程打开两个数据库(主机%应该在那里)

You can use SQLYog (mysql front end) to do it.

Meny option is Powertools -> Database Synchronization wizard

You must be able to open both database remotely (host % should be there)

放手` 2024-10-03 17:12:33

去过那里,做过那件事,实际上现在正在进行一个类似的项目。在我们的项目中,我们继承了一些我们不知道它们是什么或所有东西在哪里的东西,但这是一般流程:

  • 在新服务器上,设置任何适当的帐户
  • 如有必要,查找在哪里更改服务器和用户名/密码在应用程序配置中
  • 关闭 Web 应用程序,以便在移动时不会有任何写入
  • 移动数据库
  • 重新配置应用程序
  • 启动备份
  • 对每个数据库/应用程序重复

对于小东西,这只需要几秒钟。 SQLyog 在这里提供了很大的帮助。如果您拥有大型数据库或决定不希望出现任何停机时间,那么您需要考虑复制。

Been there, done that, and actually in the middle of a similar project right now. With our projects, we inherited a few that we don't know what they are or where everything is, but here is the general flow:

  • On new server, set up any appropriate accounts
  • Find where to change the server and username/passwords if necessary in the application config
  • Shut down the web application so there aren't any writes while moving
  • Move the DB
  • Reconfigure the app
  • Fire it back up
  • Repeat for each DB/application

For small stuff, this only takes a few seconds. SQLyog is a great help here. If you have large databases or decide you don't want any downtime, then you need to consider replication.

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