pydelion.com

How to get number of registered users in WordPress databases (if you have a lot of databases)

Task

There are a lot of WordPress based websites (as well as not WordPress) databases on your box.  It’s necessary to get  number of registered users in WordPress databases only.

Solution

Collecting WordPress databases:

mysql -Bse " use information_schema; select TABLE_SCHEMA from TABLES where table_name like 'wp_users';" > wp_users.txt

Getting the numbers:

for i in $(cat wp_users.txt ) ; do echo -n $i " "; mysql -Bse "use $i ; select count(id) from wp_users " ; echo ; done | sort -rnk2 | less
Exit mobile version