Get the number of Moodle users from the database

To find the total numbers of users from a Moodle database you can simply run a MySQL command. This can be accomplished from your control panel (cPanel, DirectAdmin etc >> phpMyAdmin) or from the command line.

To get the numbers of users from the Moodle database:

  1. Log into your control panel – cPanel, DirectAdmin
  2. Navigate to phpMyAdmin
  3. Select the Moodle database on the left.
  4. Go to the SQL tab and run the command:
 SELECT COUNT(tablerefix_user.username) FROM `tableprefix_user`

tableprefix can vary from installation to installation. In our case for example it was:

 SELECT COUNT(mdloa_user.username) FROM `mdloa_user`

The result is:

moodle users
Number of Moodle users

You can find the database name and the table prefix in the config.php file from the root of your Moodle installation:

<?php  // Moodle configuration file
$CFG->dbname    = 'plothost_mood630';
$CFG->prefix    = 'mdloa_';

For Moodle hosting plans with 24/7 technical support please visit

Leave a Reply