如何搜索和替换数据库中的字符串的所有实例? [英] How to search and replace all instances of a string within a database?
问题描述
我有一个字符串包含在wordpress安装(服务器的名称)数千次,跨多个列,记录和表。
I have a string that is contained inside of a wordpress install (the name of a server) thousands of times, across multiple columns, records and tables.
我我们正在移动内容。
因此,源代码应该是 http:// my-server1 / some / link / to / something ,我想将其替换为 http:// my-other-server / some / link / to / something 。我本质上希望为 http:// my-server1 的每个实例重复此过程。
So the source would be something like http://my-server1/some/link/to/something, and I'd want to replace it with http://my-other-server/some/link/to/something. I'm essentially looking to repeat this process for every instance of http://my-server1.
在MySQL中有一个简单的方法吗?一个工具?
Is there an easy way to do this in MySQL? A tool? Or do I sadly have to update every record problematically?
谢谢,
推荐答案
一个粗略的(但有效的)方法是将模式转储到一个文件中,仔细应用搜索和替换,然后重新导入。
A crude (but effective) way of doing it would be to dump the schema into a file, carefully apply the search-and-replace and then re-import.
事实上我今天这样做了:)
As a matter of fact I did that today :)
这篇关于如何搜索和替换数据库中的字符串的所有实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!