Search code examples
mysqlsqldatabasecommand-linemysql-variables

How to show all user-defined variables (MySQL)


I set two user-defined variables as shown below but after some time, I forgot the names:

SET @a = 2, @b = 3;

So, does MySQL have the command that displays all user-defined variables?


Solution

  • Starting with MySQL 5.7, the performance schema exposes user variables.

    See table performance_schema.user_variables_by_thread

    https://dev.mysql.com/doc/refman/5.7/en/performance-schema-user-variable-tables.html