Tool for quickly connecting to MySQL from any WP directory.
-
Hi all, as I’m working on plugins and exploring the WP core, I find that I often need to connect to MySQL to check something. I wrote a tool that searches for the wp-config.php file from any WP directory and returns the connection string.
$ pwd /var/www/wordpress/public_html/wp-content/themes $ wpdb mysql -u"AzureDiamond" -p"hunter2" -h"localhost" some_db $
It can optionally connect directly or produce a mysqldump string complete with suggested time-based filename:
$ wpdb -c Welcome to the MySQL monitor. Commands end with ; or \g. mysql> SELECT COUNT(*) FROM wp_posts; +----------+ | COUNT(*) | +----------+ | 351 | +----------+ 1 row in set (0.01 sec) mysql> EXIT; $ wpdb -d mysqldump -u"AzureDiamond" -p"hunter2" -h"localhost" some_db --skip-opt > some_db_2016-02-10_1602.sql $
You can get the tool from my Github repo:
https://github.com/dotancohen/wpdb
If you guys need any more features, or find a bug, please let me know and I’ll be happy to add it. Enjoy!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Tool for quickly connecting to MySQL from any WP directory.’ is closed to new replies.