While the link below is for version 5.7, think it applies to versions
Moodle might be running under as well.
" If you change a global system variable, the value is remembered and used for new sessions until you change the variable to a different value or the server exits. The change is visible to any client that accesses the global variable. However, the change affects the corresponding session variable only for clients that connect after the change. The global variable change does not affect the session variable for any current client sessions (not even the session within which the SET GLOBAL statement occurred).
To make a global system variable setting permanent so that it applies across server restarts, you should also set it in an option file."
And, the 'set global' will only work *IF* the DB user is the 'superuser'.
Suggest you create a text document with those global set commands for safe keeping.
Make a backup of your DB for Moodle.
Then restart your MySQL service as a test to see if your Moodle site remains accessible/usable.
If it doesn't, use your text document global commands again.
'spirit of sharing', Ken