Fix wp-config
<3
:2

Date posted: Nov. 27, 2022, midnight
Problem: blank returns from wp-cli
What does it do?: takes the db info from a wp-config file and generates a new one.
Problem: blank returns from wp-cli
What does it do?: takes the db info from a wp-config file and generates a new one.
sean@castle-murray.com[~/wp-cli] #
fix-wp-config(){ if grep 'database_name_here' wp-config.php; then echo "no valid db info to copy"; else dbname=$(awk -F "'" '/DB_NAME/ {print $4}' wp-config.php); dbuser=$(awk -F "'" '/DB_USER/ {print $4}' wp-config.php); dbpass=$(awk -F "'" '/DB_PASSWORD/ {print $4}' wp-config.php); dbhost=$(awk -F "'" '/DB_HOST/ {print $4}' wp-config.php); prefix=$(awk -F "'" '/table_prefix/ {print $2}' wp-config.php); mv wp-config.php{,-$(date -I)}; wp config create --dbname="${dbname}" --dbuser="${dbuser}" --dbpass="${dbpass}" --dbprefix="${prefix}" --dbhost="${dbhost}"; fi; }; fix-wp-config
sean@castle-murray.com[~/wp-cli] #
tmcensor@castle-murray.com[~/wp-cli] #
This works best on one line. I've tried breaking it up but it pastes weird for some reason.
tmcensor@castle-murray.com[~/wp-cli] #
A wise man once told me << DROP TABLE * is the username I use anywhere it will let me >>