飞龙记录经典mysql查询语句攻克wordpress数据库
feilong.org 修订于2011-12-29 06:02:06 您好,第 266 位朋友!总结一下经典mysql查询语句,记录备用。哈哈
部分字符串匹配查询与输出
select * from `wp_links` WHERE 1=1 and `link_image` like '%http://wp-content/%' |
部分字符串匹配查询和替换
部分字符串替换 // 飞龙备注那个 2=2 是随便弄的哈哈,注意不要是字符串,否则mysql有可能把它当字段看 update `wp_links` set `link_image`=REPLACE(`link_image`, 'http://wp-content/', 'wp-content/') WHERE 2=2 and `link_image` like '%http://wp-content/%' |
迁移WordPress用户数据库到第二个WordPress博客程序,先要把默认的第一个用户排除,然后再附加其它用户,并把wp_'替换为 'wp2_',否则WordPress role的角色配置,你会出现“no role for this site 的提示”。
update `wp2_usermeta` set `meta_key`=REPLACE(`meta_key`, 'wp_', 'wp2_') WHERE 1 =1 AND `meta_key` LIKE '%wp_%' |
wordpress 迁移数据库的常用sql命令运行 如下:
UPDATE `e0_links` set `link_url`= REPLACE(`link_url`, 'http://127.0.1.1/wifi0', 'http://wi.aneave.com') WHERE `link_url` like '%http://127.0.1.1/wifi0%' UPDATE `e0_links` set `link_image`= REPLACE(`link_image`, 'http://127.0.1.1/wifi0', 'http://wi.aneave.com') WHERE `link_image` like '%http://127.0.1.1/wifi0%' update `e0_posts` set `guid`=REPLACE(`guid`, 'http://127.0.1.1/wifi0', 'http://tanglin.aneave.com') WHERE `guid` like '%http://127.0.1.1/wifi0%'; update `e0_posts` set `post_content`=REPLACE(`post_content`, 'http://127.0.1.1/wifi0', 'http://tanglin.aneave.com') WHERE `post_content` like '%http://127.0.1.1/wifi0%'; update `e0_postmeta` set `meta_value`=REPLACE(`meta_value`, 'http://127.0.1.1/wifi0', 'http://tanglin.aneave.com') WHERE `meta_value` like '%http://127.0.1.1/wifi0%'; update `lh_options` set `option_value`=REPLACE(`option_value`, 'http://127.0.1.1/wp.com', 'http://tanglin.aneave.com') WHERE `option_value` like '%http://127.0.1.1/wp.com%'; UPDATE `wpmobi_comments` set `comment_author_url`= REPLACE(`comment_author_url`, 'http://127.0.0.1/wp.mobi?id=1', 'http://127.0.1.1/wp.mobi/creater?muid=2') WHERE `comment_author_url` like '%http://127.0.0.1/wp.mobi?id=1%' |
更新网址:https://feilong.org/mysql-wordpress-query
最初发布:20111229 06:02:06 feilong.org 于广州
加入收藏夹,查看更方便。