Created
August 31, 2011 07:28
-
-
Save ammist/1183000 to your computer and use it in GitHub Desktop.
MySQL Wrangling
This file contains 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
-- handy for moving a database from prouction to your local environment. | |
-- change URL's in wordpress single-site install. Replace with your own URL's. | |
-- this doesn't address serialized options. | |
UPDATE wp_options SET option_value = "http://localhost:8888" WHERE option_name = "home"; | |
UPDATE wp_options SET option_value = "http://localhost:8888" WHERE option_name = "siteurl"; | |
update wp_postmeta set meta_value = replace(meta_value, 'http://example.com', 'http://localhost:8888') where meta_key='_menu_item_url'; | |
update wp_posts set post_content = replace(post_content, 'http://example.com', 'http://localhost:8888'); |
This file contains 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
-- Export a mysql database from the commandline: | |
-- That chararacter set stuff isn't always needed (most SQL databases are | |
mysqldump [database] --opt -u [username] --password='[password]' --default-character-set=latin1 -N > [filename] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this to create a backup script on my development environment. Whenever I make a major change to a database, I like to back it up first.