如何搜索和替换数据库中字符串的所有实例?

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.

我想用另一台服务器的位置更新它 - 我们正在移动内容.

I'd like to update it with the location of another server - we are moving the content over.

所以源将类似于 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 :)

这篇关于如何搜索和替换数据库中字符串的所有实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)