SQL Updates for WP
By Mr.Seiko on Apr 7, 2016 | In Uncategorized
Had a customer today that fucked up his WP install.
He moved from newsite.<domain> to <domain> and didn't make any updates in the WP Admin to account for the move to the new URL as per the Moving WordPress article on Codex.
Figured I would repair the DB manually to get rid of all the 'newsite.' references.
There were over 1600 references to the site name in the DB
Figured I would write up a little SQL Script that would make the update:
UPDATE wpjc_posts set guid=REPLACE(guid, 'newsite.customerdomain.com', 'customerdomain.com')
UPDATE wpjc_posts set post_content=REPLACE(post_content, 'newsite.customerdomain.com', 'customerdomain.com')
UPDATE wpjc_postmeta set meta_value=REPLACE(meta_value, 'newsite.customerdomain.com', 'customerdomain.com')
UPDATE wpjc_options set option_value=REPLACE(option_value, 'newsite.customerdomain.com', 'customerdomain.com')
Running this, updated 2000+ records referring to the old URL in a few seconds, and was literally the quickest resolution to this issue.
No feedback yet
| « Injecting a WP-Admin User for testing | cPanel Default Page » |