How can I get server_id in MYSQL?

I mean this document. I need server_id for the short mysql uuid function.

https://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_server_id

How can I print server_id via mysql console? Thanks

+7
mysql
source share
2 answers

You can do it with

SELECT @@server_id 

as @@ points to globally defined variables (not like one @ , which is for session-defined variables)

For example,

 SELECT CONCAT(@@server_id, UUID()); 
+16
source share
 mysql> SHOW VARIABLES LIKE 'server_id'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 1 | +---------------+-------+ 1 row in set (0.01 sec) 
+6
source share

All Articles