Created
November 18, 2011 22:00
-
-
Save abackstrom/1377901 to your computer and use it in GitHub Desktop.
Update WordPress Network URLs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE wp_blogs SET domain = 'www.example.dev'; | |
UPDATE wp_site SET domain = REPLACE(domain, 'example.com', 'example.dev'); | |
UPDATE wp_sitemeta SET meta_value = REPLACE(meta_value, 'example.com', 'example.dev') WHERE meta_key = 'siteurl'; | |
UPDATE wp_domain_mapping SET meta_value = REPLACE(meta_value, 'example.com', 'example.dev'); | |
DROP PROCEDURE IF EXISTS wploop; | |
DELIMITER $$ | |
CREATE PROCEDURE wploop() | |
BEGIN | |
DECLARE done INT DEFAULT 0; | |
DECLARE tname VARCHAR(20); | |
DECLARE selsql VARCHAR(200); | |
DECLARE opttables CURSOR FOR select table_name from information_schema.tables where table_schema = 'wordpress' and table_name like 'wp\_%\_options'; | |
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; | |
OPEN opttables; | |
optloop: LOOP | |
FETCH opttables INTO tname; | |
IF done THEN | |
LEAVE optloop; | |
END IF; | |
SET @selsql = concat("UPDATE ", tname, " SET option_value = REPLACE(option_value, 'example.com', 'example.dev') WHERE option_name IN ('siteurl', 'fileupload_url', 'home');"); | |
prepare selsql from @selsql; | |
execute selsql; | |
END LOOP; | |
CLOSE opttables; | |
END;$$ | |
DELIMITER ; | |
CALL wploop(); | |
DROP PROCEDURE IF EXISTS wploop; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment