修复由于在文本编辑器中编辑MySQL数据库而导致序列化数据损坏的问题? [英] Fix serialized data broken due to editing MySQL database in a text editor?

查看:77
本文介绍了修复由于在文本编辑器中编辑MySQL数据库而导致序列化数据损坏的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我下载了WordPress网站数据库的 *.sql 备份,并用新的(例如从默认将wp_设置为asdfghjkl_).

Background: I downloaded a *.sql backup of my WordPress site's database, and replaced all instances of the old database table prefix with a new one (e.g. from the default wp_ to something like asdfghjkl_).

我刚刚了解到WordPress在数据库中使用了序列化的PHP字符串,而我所做的将使序列化的字符串长度的完整性陷入混乱.

I've just learnt that WordPress uses serialized PHP strings in the database, and what I did will have messed with the integrity of the serialized string lengths.

问题是,在我了解备份文件之前(由于我的网站仍能正常运行),我删除了备份文件,并且此后安装了许多插件.因此,我无法还原,因此我想知道两件事:

The thing is, I deleted the backup file just before I learnt about this (as my website was still functioning fine), and installed a number of plugins since. So, there's no way I can revert back, and I therefore would like to know two things:

  1. 如何解决这个问题?

  1. How can I fix this, if at all possible?

这可能会导致什么问题?

What kind of problems could this cause?

(本文指出,例如WordPress博客可能会丢失它的设置和小部件.但这似乎并没有发生,因为我博客的所有设置仍然完好无损.未来.因此这个问题.)

(This article states that, a WordPress blog for instance, could lose its settings and widgets. But this doesn't seem to have happened to me as all the settings for my blog are still intact. But I have no clue as to what could be broken on the inside, or what issues it'd pose in the future. Hence this question.)

推荐答案

访问此页面: http://unserialize. onlinephpfunctions.com/

在该页面上,您应该看到以下示例序列化字符串:a:1:{s:4:"Test";s:17:"unserialize here!";}.拿一块-s:4:"Test";.意思是字符串",四个字符,然后是实际的字符串.我很确定您所做的操作导致数字字符计数与字符串不同步.在上述站点上使用该工具,例如,如果将测试"更改为"Tes",则会看到错误消息.

On that page you should see this sample serialized string: a:1:{s:4:"Test";s:17:"unserialize here!";}. Take a piece of it-- s:4:"Test";. That means "string", 4 characters, then the actual string. I am pretty sure that what you did caused the numeric character count to be out of sync with the string. Play with the tool on the site mentioned above and you will see that you get an error if you change "Test" to "Tes", for example.

您需要做的是获取那些字符数以匹配您的新字符串.如果您还没有破坏其他任何编码-删除了冒号或其他内容-应该可以解决此问题.

What you need to do is get those character counts to match your new string. If you haven't corrupted any of the other encoding-- removed a colon or something-- that should fix the problem.

这篇关于修复由于在文本编辑器中编辑MySQL数据库而导致序列化数据损坏的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆