How to display the value of a variable at the commandline in MySQL?

Simply SELECT the variable like this:

SELECT @myId;

Here is the MySQL documentation on user-defined variables:

http://dev.mysql.com/doc/refman/5.5/en/user-variables.html


SHOW GLOBAL STATUS LIKE '%com_stmt%'; may be used to determine any SHOW GLOBAL STATUS current values using wildcard.

Likewise, SELECT @@thread_cache_size; may be used to display any specific SHOW GLOBAL VARIABLES current value.

There are more than 300 GLOBAL STATUS values.

There are more than 400 GLOBAL VARIABLES with or without values. (Could be empty placeholders).

You CAN NOT create a GLOBAL VARIABLE in MySQL.


If you're looking for a variable that you set yourself like the OP did, then @MikeBrant's answer is correct:

SELECT @myId;

But if you want to see the MySQL system variables (which is what I came here looking for), then you need to run:

show variables like '%slow%';

or possibly:

show global variables like '%slow%';