wordpress 数据库_如何同步WordPress Live和开发数据库

wordpress 数据库

database synchronization

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。

Developing WordPress themes is considerably easier with real content. Unexpected situations begin to arise when people add pages, posts, media and comments. Your beautiful template can break when:

使用实际内容开发WordPress主题要容易得多。 当人们添加页面,帖子,媒体和评论时,意外情况开始出现。 在以下情况下,您漂亮的模板可能会损坏:

  • editors use assets which are too big or small for your breakpoints to handle

    编辑器使用的资产太大或太小而断点无法处理
  • managers introduce a new menu item which doesn’t fit at lower screen sizes

    管理人员介绍了一个新的菜单项,该菜单项不适用于较小的屏幕尺寸
  • your theme implements a two-level menu hierarchy which fails to cater for the inevitable third-level page

    您的主题实现了两级菜单层次结构,无法适应不可避免的第三级页面
  • long or deeply-nested comments become unreadable.

    冗长或嵌套太深的注释变得不可读。

Ideally, your development server should have a snapshot of your live production server’s database. Your workflow can be improved further if content is automatically synchronized when changes occur.

理想情况下,您的开发服务器应具有实时生产服务器的数据库的快照。 如果在发生更改时自动同步内容,则可以进一步改善您的工作流程。

同步障碍 (Synchronization Snags)

One-way WordPress database replication can be more challenging than you expect. There are good reasons why few coders live in this development dreamland…

单向WordPress数据库复制可能比您预期的更具挑战性。 有充分的理由说明为什么很少有编码员生活在这个发展的梦想中……

数据差异 (Data Differences)

WordPress stores various configuration settings in its database. This includes the domain name and paths which are used throughout posts and asset references. Importing this information into a local database (perhaps hosted at http://localhost/) will lead to undesired consequences. It may look as though it worked but image and link URLs could be taking you back to the live server.

WordPress将各种配置设置存储在其数据库中。 这包括整个帖子和资产参考中使用的域名和路径。 将此信息导入本地数据库(可能托管在http:// localhost /中)将导致不良后果。 看起来好像可行,但是图像和链接URL可能会将您带回实时服务器。

To add to the complications, WordPress serializes some data. It can be difficult to parse and change those values.

为了增加复杂性,WordPress会序列化一些数据。 解析和更改这些值可能很困难。

多种安装 (Multiple Installations)

Synchronization is less necessary and complicated when you’re a sole developer working on a local installation and uploading to a single live server. Life is more complicated for teams with multiple developers, staging servers, and possibly more than on production server.

如果您是唯一的开发人员,需要进行本地安装并上载到单个实时服务器,那么同步就没有必要,而且比较复杂。 对于拥有多个开发人员,登台服务器且可能比生产服务器更多的团队而言,生活更加复杂。

数据库可能很大 (Databases can be Large)

SitePoint runs on WordPress and contains many thousand articles, drafts and revisions. Even if fast incremental synchronization were implemented, you’re unlikely to want or need numerious megabytes of post data.

SitePoint在WordPress上运行,并包含数千篇文章,草稿和修订版。 即使实现了快速增量同步,您也不太可能想要或需要大量兆字节的发布数据。

不只是数据库 (It’s Not Just Databases)

WordPress stores uploaded images and other media in the local file system. Those need to be downloaded and the database references must be updated accordingly.

WordPress将上传的图像和其他媒体存储在本地文件系统中。 需要下载这些文件,并且必须相应地更新数据库引用。

You must also ensure theme and plugin files are synchronized, enabled and configured appropriately. That said, you possibly do not want certain plugins enabled, e.g. multi-site, caching, etc.

您还必须确保正确同步,启用和配置了主题和插件文件。 也就是说,您可能不希望启用某些插件,例如多站点,缓存等。

这很危险! (It’s Dangerous!)

Could your synchronization process fail? Is it possible for synchronization to be mis-configured so development data goes live? Is there a risk the live database can be corrupted or wiped?

同步过程会失败吗? 同步配置是否可能被错误配置,以便开发数据上线? 实时数据库可能会被破坏或擦除吗?

Absolutely.

绝对。

Whatever solution you choose, ensure you have regular file and database back-ups from your live and development servers. Imagine losing everything. A few minutes spent running mysqldump is less troublesome than many days spent re-writing lost content!

无论选择哪种解决方案,请确保从实时服务器和开发服务器进行常规的文件和数据库备份 。 想象一下,失去一切。 花几分钟时间运行mysqldump不会比花很多天重写丢失的内容麻烦得多!

可以同步吗? (Is Synchronization Possible?)

Yes, but there’s no one-size-fits-all option. You may need two-way database synchronization. You may want one-way replication from live to development servers. Or you may want to push from development to live. You may require just pages. Or do you want posts, comments, users and other data? Is database data enough or do you want all media assets? Would you prefer to synchronize manually, at predefined intervals, or automatically?

是的,但是没有一种“万能的”选择。 您可能需要双向数据库同步。 您可能需要从实时服务器到开发服务器的单向复制。 或者,您可能希望推动开发的发展。 您可能只需要页面。 还是您想要发布,评论,用户和其他数据? 数据库数据是否足够?您是否需要所有媒体资产? 您希望手动,以预定义的时间间隔还是自动进行同步?

One or more of the following options may be appropriate depending on your circumstances…

根据您的情况,以下一个或多个选项可能适用。

WP Migrate DB Pro (WP Migrate DB Pro)

Perhaps the best-known and easiest choice is the WP Migrate DB Pro WordPress plugin from Delicious Brains. The commercial product has a Media Files add-on and multi-site capabilities but a free edition is also available.

也许最著名和最简单的选择是Delicious Brains的WP Migrate DB Pro WordPress插件。 商用产品具有Media Files附加组件和多站点功能,但也提供免费版本

Note data is pulled using in-browser Ajax methods so large databases can take time to synchronize.

注意数据是使用浏览器内Ajax方法提取的,因此大型数据库可能需要一些时间才能进行同步。

WP同步数据库 (WP Sync DB)

WP Sync DB is an open-source fork of WP Migrate DB.

WP Sync DB是WP Migrate DB的开源分支。

版本新闻 (VersionPress)

VersionPress is a Git-based version control plugin for WordPress which can manage database merging. The product is in development but seems promising.

VersionPress是适用于WordPress的基于Git的版本控制插件,可以管理数据库合并。 该产品正在开发中,但看起来很有希望。

WPSiteSync for Content (WPSiteSync for Content)

Offering free and commercial editions, WPSiteSync permits real-time synchronization of pages, posts and other data.

提供免费和商业版本 ,WPSiteSync允许页面,帖子和其他数据的实时同步。

数据库同步 (Database Sync)

Database Sync is a free database-only synchronization WordPress plugin. It has not been updated for some time and is not compatible with multi-site installations but may be enough for some developers.

Database Sync是一个免费的仅数据库同步WordPress插件。 它已经有一段时间没有更新了,并且与多站点安装不兼容,但是对于某些开发人员来说可能就足够了。

WordPress导入器 (WordPress Importer)

If you prefer a safer, more manual process, WordPress Importer exports posts, pages, comments, categories, tags, authors and other data to an XML file which can be imported into another installation. This is also a good option if you are building a live site from posts in a development system.

如果您希望使用更安全,更手动的流程,则WordPress导入器会将帖子,页面,评论,类别,标签,作者和其他数据导出到XML文件,该文件可以导入到另一个安装中。 如果要通过开发系统中的帖子构建实时网站,这也是一个不错的选择。

同步数据库 (SyncDB)

SyncDB is a bash script which synchronizes local and remote WordPress databases.

SyncDB是一个bash脚本,用于同步本地和远程WordPress数据库。

WP分期 (WP Staging)

The WordPress WP Staging plugin is able to clone data and files from live to development or staging servers.

WordPress WP Staging插件能够将数据和文件从实时复制到开发或登台服务器。

WordPress GitHub同步 (WordPress GitHub Sync)

The WordPress GitHub Sync plugin allows you to synchronize content allows you synchronize content from a GitHub repository or Jekyll-created website. This could be an interesting option for teams requiring content editing collaboration and pull request approval workflows.

WordPress GitHub Sync插件允许您同步内容,允许您同步来自GitHub存储库或Jekyll创建的网站的内容。 对于需要内容编辑协作和请求请求批准工作流的团队来说,这可能是一个有趣的选择。

PushLive (PushLive)

The PushLive plugin duplicates staging to live sites with a single click. Multi-site WordPress installations are supported.

只需单击一下,PushLive插件就会将登台复制到实时站点。 支持多站点WordPress安装。

WP驿马车 (WP Stagecoach)

A commercial online service which allows staging data to be merged into your live database.

商业在线服务,允许将登台数据合并到您的实时数据库中。

MySQL同步工具 (MySQL Synchronization Tools)

Most good MySQL database management tools offer database import, export and/or synchronization facilities. The free MySQL Workbench or is a good place to start. More advanced tools such as SymmetricDS provide features such as data transformation and filtering. Finally, you could consider options such as MySQL replication to automatically replicate data from the live master database to development slaves.

大多数优秀MySQL数据库管理工具都提供数据库导入,导出和/或同步功能。 免费的MySQL Workbench还是一个不错的起点。 诸如SymmetricDS之类的更高级的工具提供诸如数据转换和过滤之类的功能。 最后,您可以考虑使用诸如MySQL复制之类的选项来将数据从实时主数据库自动复制到开发从数据库。

建立自己的解决方案 (Build Your Own Solution)

The only perfect solution is the one you build for your own requirements. The following tools may help:

唯一完美的解决方案是您根据自己的需求构建的解决方案。 以下工具可能会有所帮助:

  • mysqldump — the original MySQL schema and data back-up utility

    mysqldump —原始MySQL模式和数据备份实用程序

  • mysqlpump — a new MySQL back-up utility introduced in v5.7.8 which should offer faster parallel processing and compression. Note that it is not backward-compatible with earlier versions of the database.

    mysqlpump -v5.7.8中引入的新MySQL备份实用程序,应提供更快的并行处理和压缩。 请注意,它与数据库的早期版本不向后兼容。

  • rsync — incremental file transfer

    rsync-增量文件传输

  • Git deployment options such as WP Pusher, Beanstalk and DeployBot

    Git部署选项,例如WP PusherBeanstalkDeployBot

  • task runners such as Gulp.js or PHP alternatives such as Robo, Task and Bldr.

    诸如Gulp.js之类的任务运行器,或诸如RoboTaskBldr之类PHP替代品。

Do you have a perfect WordPress development and deployment workflow? Please leave your suggestions below!

您是否拥有完善的WordPress开发和部署工作流程? 请在下面留下您的建议!

For awesome WordPress hosting, we recommend SiteGround. SiteGround offers automated WordPress core and plugin updates, daily backups, and SSL certificates for free in every plan.

对于很棒的WordPress托管,我们建议使用SiteGround SiteGround在每个计划中免费提供自动WordPress核心和插件更新,每日备份以及SSL证书。

翻译自: https://www.sitepoint.com/synchronize-wordpress-live-development-databases/

wordpress 数据库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值