Login to Mysql (notice username and password touch the -u and -p argument)

mysql> SHOW databases;

mysql> USE wpdb;

NOTE: we can skip asking mysql to USE a database and immediately enter it from the shell prompt by running this:
mysql -uusername -ppassword wpdb. This way we dont have to ask to use wpdb, as we will already be using it.

mysql> SHOW tables;

Lets see what kind of information is saved about each user.

mysql> DESCRIBE wp_users;

We could list each user with

mysql> SELECT * FROM wp_users;

NOTE: the users passwords are encrypted, so this is secure for your users

If you want to run that command from command line. There are several ways.
I like to make a config file with the command in it
So lets make a file called /tmp/sql.txt (or anything) and its contents will only contain:
SELECT * FROM wp_users;
So we make it like this
echo ‘SELECT * FROM wp_users;’ > /tmp/sql.txt
Now to run it like this:
mysql -uusername -ppassword wpdb < /tmp/sql.txt
NOTE: becareful not to put anything damaging into /tmp/sql.txt, or else you could potentially damage your entire userdatabase.
You will see the output of all of the users. Now dont forget to clean up after yourself /tmp/sql.txt. rm /tmp/sql.txt

Here my creations. Edit username and password.

List every usersĀ info (all info) – not useful to share with world (too much data)

NOTE: I dont use above as it just lists everything about every user (its just the example in the article but in a nice copy pasteable form you can test)

List which days had the most new users

List how many new users each day (0 user days are not shown) – before to now

List how many new users each day (0 user days are not shown) – now to before

Put into a script

NOTE: you can have the results present to your wordpress viewers. you can do something like “mkdir /var/www/usercount”. And append “> /var/www/usercount/count1.txt” at the end of each file (change count1 to something meaningful). That way you can access your counts from: http://yourwebsite.com/usercount/usercount1.txt. Like this:
http://ram.kossboss.com/usercount/perday.txt
http://ram.kossboss.com/usercount/history.txt

At the end of one of my backup scripts (I do this after backup just in case anything goes wrong with the sql command – which shouldnt happen, unless there is gamma ray bursts and dark solar nuclear thin blasts, etc..):

The end.

Leave a Reply

Your email address will not be published. Required fields are marked *