Joined June 2013
·

Alex Goretoy

United States
·
·

Posted to Make postgres default to UTF8 over 1 year ago
update pg_database set encoding = 6, datcollate = 'en_US.UTF8', datctype = 'en_US.UTF8' where datname = 'template0';
update pg_database set encoding = 6, datcollate = 'en_US.UTF8', datctype = 'en_US.UTF8' where datname = 'template1';
Posted to SQL to Change WordPress Domain URL over 1 year ago

I do the same thing, only I also do extra run for escaped urls, and include any plugin tables too.

LOCAL_DOMAIN="example.local";
SITE_DOMAIN="www.example.com";

WP_DIR="wp";

LOCAL_URL="http://$LOCAL_DOMAIN";
LOCAL_URL_="http:\/\/$LOCAL_DOMAIN";
SITE_URL="http://$SITE_DOMAIN";
SITE_URL="http:\/\/$SITE_DOMAIN";
LOCAL_WP_URL="$LOCAL_URL/$WP_DIR";
LOCAL_WP_URL_="$LOCAL_URL\/$WP_DIR";
SITE_WP_URL="$SITE_URL/$WP_DIR"
SITE_WP_URL_="$SITE_URL\/$WP_DIR"

mysql -u"$DB_USER" -p"$DB_PASSWORD" -h"$DB_HOST" "$DB_NAME" << EOFMYSQL
UPDATE $DB_NAME.wp_options SET option_value = replace(option_value, '$LOCAL_WP_URL', '$SITE_WP_URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE $DB_NAME.wp_options SET option_value = replace(option_value, '$LOCAL_URL', '$SITE_URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE $DB_NAME.wp_posts SET guid = replace(guid, '$LOCAL_WP_URL','$SITE_WP_URL');
UPDATE $DB_NAME.wp_posts SET guid = replace(guid, '$LOCAL_URL','$SITE_URL');
UPDATE $DB_NAME.wp_posts SET post_content = replace(post_content, '$LOCAL_WP_URL', '$SITE_WP_URL');
UPDATE $DB_NAME.wp_posts SET post_content = replace(post_content, '$LOCAL_URL', '$SITE_URL');
UPDATE $DB_NAME.wp_postmeta SET meta_value = replace(meta_value,'$LOCAL_WP_URL','$SITE_WP_URL');
UPDATE $DB_NAME.wp_postmeta SET meta_value = replace(meta_value,'$LOCAL_URL','$SITE_URL');

UPDATE $DB_NAME.wp_links SET link_target = replace(link_target,'$LOCAL_WP_URL_','$SITE_WP_URL_');
UPDATE $DB_NAME.wp_links SET link_target = replace(link_target,'$LOCAL_URL_','$SITE_URL_');
UPDATE $DB_NAME.wp_usermeta SET meta_value = replace(meta_value,'$LOCAL_WP_URL_','$SITE_WP_URL_');
UPDATE $DB_NAME.wp_usermeta SET meta_value = replace(meta_value,'$LOCAL_URL_','$SITE_URL_');
EOFMYSQL

218 git
49 ls
38 cd
22 sudo
21 composer
19 bower
14 nano
13 ssh
12 al
9 grep

Posted to phpinfo() the right way! over 1 year ago

Very good points and nice elaboration, thanks

Achievements
165 Karma
12,176 Total ProTip Views