0
How to change the permission of an ordinary user to an administrator user in Moodle3.3 via SQL commands.
0
How to change the permission of an ordinary user to an administrator user in Moodle3.3 via SQL commands.
1
The site administrator function is allowed to do anything in Moodle, so use with caution.
You’ll need to know the user ID first - so recover the table id
SELECT *
FROM mdl_user
Then add the id to the value column here
SELECT *
FROM mdl_config
WHERE name = 'siteadmins'
For example
UPDATE mdl_config
SET value = value || ',3'
WHERE name = 'siteadmins'
You’ll probably need to go out and come back again so it can affect.
This only works for site administrators. For other functions, you need to log in as administrator and go to admin site -> users -> Permissions
Browser other questions tagged moodle
You are not signed in. Login or sign up in order to post.
It had deleted all users from the Moodle database. There is no administrator user in the database. So I created a user and I can log in, but I wanted to put administrator permission. The commands did not work, it would have another way to make this user an administrator of the system?
– Ezequias Silva
It’s kind of weird that they don’t work ?
– Otto
Actually give no error and while logging in again is displayed the common user view.
– Ezequias Silva
Any possibility of changing the admin group > "siteadmins" ?
– Otto
I created the user through the command below. Would you already be able to create the administrator user directly by sql command? INSERT INTO mdl_user (firstname,lastname,email,username,password,Confirmed,Description, mnethostid) VALUES ('admin','city','[email protected]','admin',MD5('test'),1,'Test environment',1);
– Ezequias Silva
Well confirming that you have executed the correct commands ... in select you take your user id to add in the update, you did this ? @Ezequiassilva
– Otto
Yes. I did exactly as the commands say. I am using Moodle3.3. This influences?
– Ezequias Silva
You’d have to see if there’s any table of roles
– Otto
I’m not at work now. I’ll get back to you tomorrow. I’ve already scoured the net and found none of it. Your help will be very welcome.
– Ezequias Silva
Then, in the table mdl_role has this: id: 1 shortname: manager Sortorder: 1 archetype: manager
– Ezequias Silva
I also have the table mdl_role_allow_assign with id, roleid and allowassign. I don’t see any relation to the user id. I ask for understanding through ignorance.
– Ezequias Silva