MySQL 替换 text 字段中的指定字符串

更新日期: 2018-01-06 阅读次数: 12772 分类: MySQL

昨天将博客启用了 HTTPS,发现一个包含 js 的 markdown 文章显示异常。

vuejs 中如何优雅的获取 Input 值

导致异常的原因是,https 页面引用了 http 的 js 文件,即 vuejs 的 cdn 链接使用了 http 的。

解决方法就是直接在 mysql 中进行替换

UPDATE articles SET content = REPLACE(content, "http", "https") where slug = 'how-to-get-input-value-in-vuejs'; 

如果需要批量替换数据表中的 http 为 https

UPDATE articles SET content  = REPLACE(content, 'http:', 'https:') WHERE INSTR(content, 'http:') > 0;

INSTR

Returns the position of the first occurrence of substring substr in string str.

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式