Matthew Ames

WordPress

Matthew Ames - 2016-03-01 - 8:38 am

Here’s a few commands to find out the siteurl and home directives in wordpress. Run this from the same location as wp-config.php

USER=`grep DB_USER wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
PASSWORD=`grep DB_PASSWORD wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
HOST=`grep DB_HOST wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
DB=`grep DB_NAME wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
PREFIX=`grep table_prefix wp-config.php | awk '{print $3}' | sed -e "s|'\(.*\)';|\1|"`
QUERY="select option_id,option_name,option_value from "$PREFIX"options where option_name='siteurl' or option_name='home';"
mysql -u$USER -p$PASSWORD -h $HOST $DB -e "$QUERY"

You may then wish to edit the siteurl and home directives in wordpress. If so, try the below:

URL=http://domain.tld
USER=`grep DB_USER wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
PASSWORD=`grep DB_PASSWORD wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
HOST=`grep DB_HOST wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
DB=`grep DB_NAME wp-config.php | awk '{print $2}' | sed -e "s|'\(.*\)');|\1|"`
PREFIX=`grep table_prefix wp-config.php | awk '{print $3}' | sed -e "s|'\(.*\)';|\1|"`
QUERY="update "$PREFIX"options set option_value='$URL' where option_name='siteurl' or option_name='home';"
mysql -u$USER -p$PASSWORD -h $HOST $DB -e "$QUERY"
define( 'FS_METHOD', 'ftpext' );
define( 'FTP_BASE', '/path/to/wordpress/' );
define( 'FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/' );
define( 'FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/' );
#define( 'FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub' );
#define( 'FTP_PRIKEY', '/home/username/.ssh/id_rsa' );
define( 'FTP_USER', 'username' );
define( 'FTP_PASS', 'password' );
define( 'FTP_HOST', 'ftp.example.org' );
define( 'FTP_SSL', false );
0 Comments