MySQL 批量更换指定字符串的函数:replace(str,old_string,new_string),比如全站开启https时,需要将原有的http替换为https就可以使用replace函数,直接在数据库中执行replace函数即可,简单快捷。
replace(str,old_string,new_string) 参数说明:
- str:字段
- old_string:旧的字符串
- new_string:新的字符串
例如 posts表内content字段中http替换为https的语句:
UPDATE posts SET content=replace(content, ‘http’,’https’)