简体   繁体   中英

How can i get server_id in MYSQL?

I am referring this document. I require server_id for uuid short function of mysql.

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

How can i print server_id through mysql console? Thanks

You can do it with:

SELECT @@server_id

as @@ points to global-defined variables (not like single @ which is for session-defined variables)

For example,

SELECT CONCAT(@@server_id, UUID());
mysql> SHOW VARIABLES LIKE 'server_id';

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 1     |
+---------------+-------+

1 row in set (0.01 sec)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM