要把数据库中某个列的所有值中含有”test.trustauth.cn”的字符更换成”www.trustauth.cn”,方法有几种,如shell脚本,但是这样效率非常低,但Mysql中有replace函数很容易实现替换。
replace(str,from_str,to_str)
在字符串 str 中所有出现的字符串 from_str 均被to_str替换,然后返回这个字符串
如你要将表wp_posts里面的guid字段的http://test.trustauth.cn/…替换为http://www.trustauth.cn/…:
update wp_posts set guid=replace(guid,’http://test.trustauth.cn/’,’http://www.trustauth.cn/’);