|

楼主 |
发表于 2024-1-20 09:44
|
显示全部楼层
- select * from pre_forum_post where author="admin" and subject="测试回复可见";
- update pre_forum_post set message=REPLACE(message,'[hide]回复可见的内容4[/hide]','[hide]回复可见的内容5[/hide]') where author="admin" and subject="测试回复可见";
- ###########replace里面不能有正则表达式
- update pre_forum_post set message=REPLACE(message,'[hide]*[/hide]','[hide]回复可见的内容5[/hide]') where author="admin" and subject="测试回复可见";
- ###########
- 直接修改帖子内容 有换行
- update pre_forum_post set message='[hide]回\r
- 复\r
- 可\r见\r的\r内容6[/hide]' where author="admin" and subject="测试回复可见";
- 用ssh执行mysql语句
- ##########################下面的脚本可以用 但是用户不能用root 必须创建一个有密码的用户
- #!/bin/bash
- #连接MySQL数据库
- Host=127.0.0.1
- User=root
- PASSWORD=
- PORT=3306
- DBNAME="d2mods"
- TABLENAME="pre_forum_post"
- SQL="update ${DBNAME}.${TABLENAME} set message=REPLACE(message,'[hide]回复可见的内容4[/hide]','[hide]回复可见的内容5[/hide]') where author='admin' and subject='测试回复可见'"
- #mysql -h${Host} -port${PORT} -u${User} -p${PASSWORD} -D${DBNAME} -e"select count(*) from resources"
- #mysql -h"127.0.0.1" -port"3306" -uuser -ppassword -D"appdb" -e"select count(*) from resources"
- #本地连接
- mysql -h${Host} -port${PORT} -u${User} -p${PASSWORD} <<EOF
- use ${DBNAME};
- ${SQL};
- COMMIT;
- EOF
- echo "create yes"
- ##########################
- ##########################下面精简为一句话的脚本 用户不能用root 必须创建一个有密码的用户
- mysql -uroot -p -D"d2mods" -e"update pre_forum_post set message=REPLACE(message,'[hide]回复可见的内容5[/hide]','[hide]回复可见的内容6[/hide]') where author='admin' and subject='测试回复可见';"
- ################为了方便换行 直接把下面的语句放到脚本里面执行 也行 这样看着方便点
- mysql -uroot -p -D"d2mods" -e"update pre_forum_post set message='[hide]回\r
- 复\r
- 可\r见\r的\r内容7[/hide]' where author='admin' and subject='测试回复可见';"
复制代码 直接用ssh执行mysql语句
|
|