brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp config create with prompt keeps the WordPress database password out of history

WordPress
~/tips/tip-wordpress-config-create-prompt-pass

wp config create --dbname=example_wp --dbuser=example --prompt=dbpass

Generates wp-config.php with fresh salts while the password never appears on the command line.

wp config create writes a complete wp-config.php, salts included. The usual example puts the database password right on the command line, which I’d rather avoid.

wp config create --dbname=example_wp --dbuser=example --prompt=dbpass

--prompt=dbpass asks for that one value interactively, so it does not end up in ~/.bash_history or in the process list. In a script you can feed it from a file instead, as the docs show:

wp config create --dbname=example_wp --dbuser=example --prompt=dbpass < password.txt

Other options: --dbhost (default localhost), --dbprefix (default wp_) and --locale. --extra-php reads more PHP from standard input and puts it in the file, handy for WP_DEBUG or WP_ENVIRONMENT_TYPE lines.

By default it connects to the database first and stops when the credentials are wrong, which I appreciate, because a typo shows up right away. --skip-check turns it off, for example when the database server isn’t up yet in a container setup. It won’t overwrite an existing wp-config.php unless you pass --force, and with --force you also get new salts, which logs everyone out.

Further reading: wp config create

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link