Change user group from backend
How to change user group of a user from backend via MySQL queries?
Overview: This article explains how to change a user's group in gateway server from the backend using MySQL queries by identifying the database details, retrieving the user group ID, and updating the user’s group with a query runner command.
User groups can be updated from the backend using MySQL queries instead of utilizing the web GUI.
Follow the steps below to update the user group of a gateway user.
Step 1: Find out the database name and database table prefix using below command.
root@gateway:~# cat /usr/local/etc/ezlogin/ez.conf | grep -i "db_name\|db_prefix"
Example : root@gateway:~# cat /usr/local/etc/ezlogin/ez.conf | grep -i "db_name\|db_prefix"
db_name ezlogin_ujnq
db_prefix pyvzbw_
Step 2: Run below command to find the usergroup ID and replace database name and database table prefix.
root@gateway:~# mysql -u root -p -e "use database name ; select id,name from dbprefix_usergroups;"
Example : root@gateway:~# mysql -u root -p -e "use ezlogin_ujnq; select id,name from pyvzbw_usergroups;"
Enter password:
+----+---------+
| id | name |
+----+---------+
| 1 | Admins |
| 2 | Dummy |
| 3 | Develop |
+----+---------+
Step 3: Run below queryrunner command and replace username and usergroup ID to change the usergroup.
root@gateway:~# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users set usergroup_id=1 where username='user_name'"
Example : root@gateway:~# php /usr/local/ezlogin/ez_queryrunner.php "update prefix_users set usergroup_id=3 where username='John'"
update pyvzbw_users set usergroup_id=4 where username='John'
Success
Initially, gateway user Jimmy is part of the 'Admins' user group.
Gateway user Jimmy has been changed from the 'Admins' user group to the 'Develop' user group.
Related Articles: