简体   繁体   中英

How to change user permissions via MySQL in Moodle?

I need to change a user's role to admin in a Moodle installation (I'm not knowledgeable in Moodle whatsoever), since I've got not access to the backoffice or admin tools. I can only access the database.

I've been looking at the several tables and their documentation but I can't seem to find which table has the user permissions?

The site admin role has permission to do anything in Moodle, so use with caution.

You will need to know the user id first - so retrieve the id from this table

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 will probably need to log out and back in again for this to take affect.

This is only works for site admins. For other roles you will need to log in as an admin and go to site admin -> users -> permissions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM