测试数据库的最佳方法是什么(特定于 MYSQL)

发布于 2024-08-29 12:53:24 字数 543 浏览 2 评论 0原文

现在我正在数据库中测试一些东西。这是一个 WordPress 数据库。我必须对其进行写入和删除以及其他操作。如您所知,它具有索引机制,始终使每个新帖子继承下一个可能的最高 ID。

请考虑该数据库是已用数据库的副本。以前已经写过。 所以,我需要确保当我完成测试时,它会是相同的

现在,我唯一的解决方案是进行备份。因此,如果我结束了计划测试的某些部分,我将备份它并开始对其另一个副本进行下一次测试。

幸运的是,数据库的大小很小。所以删除、复制和备份会很容易。但我知道这种数据库测试方法只是部分解决方案。它迫使我创建太多的备份副本。我不知道如果数据库更大的话我会做什么。这将是一场漫长的测试噩梦。

所以我想知道是否有任何解决方案可以像回滚一样工作。所以它只会锁定数据库并将新条目作为某种缓存。 我可以删除它或者将它写入数据库。

我使用 mysql 和 phpmyadmin 并用它来开发一些自定义解决方案。

编辑 ::: 在开发 PHP 解决方案时如何有效地对数据库进行测试?

Right now i'm on testing something in a database. It's a wordpress database. i have to write and delete and do other operation on it. As you know it, it has indexing mechanism that will always make every new post inherit the next highest possible ID.

Please consider that this database is a copying of used database. it has been written before. So, i will need to make sure when i finish my testing, it will be the same

Right now, my only solution is making backup. So if i have end in some section of planned testing, i will backup it and start next testing on another copy of it.

Fortunately, the size of database is only a small one. so delete and copy and backup it will be easy. but i know this way of database testing is only partial solution.It force me to create too many backup copy. I don't know what i will do if the database has bigger size. it will be a very long of testing nightmare.

so i wonder is there any solution that work just like rollback. So it will just lock the database and just put new entry as some kind of cache. I can erase it or write it into the database.

i use mysql and phpmyadmin and use it to developed some custom solution.

EDIT ::: How to effectively doing testing on database when developing PHP solution ?

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

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

发布评论

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

评论(3

梦幻之岛 2024-09-05 12:53:24

如果您的文件系统支持可写快照 - LVM、ZFS、Veritas 等 - 您可以获取整个数据库分区的即时副本,将其安装在另一个位置,启动使用快照的新 MYSQL 实例,执行测试,删除您的快照 - 一切都不会影响您的副本。

快照仅需要存储测试期间更改的数据量,因此可能只需要几 GB。

If your file system supports writeable snapshots - LVM, ZFS, Veritas, etc. - you can take an instant copy of the entire database partition, mount that in another place, start a new instance of MYSQL which uses the snapshot, perform your testing, remove your snapshot - all without disturbing your replica.

The snapshot only needs storage for the amount of data that gets changed during your testing, and so might only need a few GB.

深海里的那抹蓝 2024-09-05 12:53:24

删除记录后,当您插入新记录时,如果您将 id 设置为您想要的数字,而不是将其留空,它应该再次填充该索引。

After you delete the record, when you insert the new record, if you set the id to the number you want, rather than leaving it blank, it should just fill that index again.

清风无影 2024-09-05 12:53:24

帖子编号是自增字段吗?如果没有,请(暂时)侵入 WordPress 并查找存储新帖子的代码。在保存之前,为什么不添加一个常量,例如 1000 到帖子 ID 号。完成测试后,只需删除大于常量的 id 编号即可。

Is the post number an autoincrement field? If not, hack into WordPress (temporarily) and look for the code where the new posts are stored. Before saving why don't you add a constant e.g. 1000 to post id number. When you are finished with your testing simply delete the id numbers that are greater than your constant.

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