Quickly View WordPress DB Credentials
Dec 18, 2009 | Web Design & Development | By Shawn Parker
Stupid Gippy Trick #2495: The title may sound funny, and the concept a bit weird, but when you’re working on many different client servers, development and production servers, with as many different configurations, keeping track of DB credentials can get a little tiresome and time consuming.
Here’s a command line one liner to print the database credentials so that they’re easily used to manually log in to MySQL or do a database dump:
$ grep DB_ wp-config.php
Which prints out:
define('DB_NAME', 'putyourdbnamehere'); define('DB_USER', 'usernamehere'); define('DB_PASSWORD', 'yourpasswordhere'); define('DB_HOST', 'localhost'); define('DB_CHARSET', 'utf8'); define('DB_COLLATE', '');
Voila! No more switching back and forth from a credentials file or database or get the credentials, you simply use that’s already there.
Somebody more ambitious could probably make a little function that parses that output and creates a MySQL login command or mysqldump command, but right now that’s not me. 😉
Tagged as: credentials, ssh, terminal, wordpress