MariaDB – Grants for Setting Session Variables

mariadbsession

On MariaDB, what grants are needed for set session variables?

For set global are the SUPER grants. But can any client without SUPER grants set his own session variables?

Best Answer

Yes, this appears to be the case - you don't need any particular GRANT in order to modify your own session variables:

CREATE USER user1@localhost IDENTIFIED BY 'Password_123!';
SHOW GRANTS FOR user1@localhost;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user1@localhost                                                                                   |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'user1'@'localhost' IDENTIFIED BY PASSWORD '*45C046113DAFA331183C338569DC015C53EE4B47' |
+--------------------------------------------------------------------------------------------------------------+
1 row in set (0.05 sec)

Then:

# mysql -u user1 -p'Password_123!'

SHOW VARIABLES LIKE 'sql_mode';
+---------------+--------------------------------------------+
| Variable_name | Value                                      |
+---------------+--------------------------------------------+
| sql_mode      | NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+--------------------------------------------+
1 row in set (0.03 sec)
SET sql_mode='';
SHOW VARIABLES LIKE 'sql_mode';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_mode      |       |
+---------------+-------+
1 row in set (0.01 sec)

Note that of course not all system variables can be modified per session, and some are not even dynamic.