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
In MySQL 5.7, server_id must be specified if binary logging is enabled, otherwise the server is not allowed to start. server_id is set to 0 by default. On a replication source server and each replica, you must specify server_id to establish a unique replication ID in the range from 1 to 232 − 1.
To get the server_id, use the system defined variable @@server_id. You cannot use only a single @ as user defined variable for server_id. As an alternate, you can use SHOW VARIABLES command.
First, this means there is a new file (in 5.6+) located in the datadir named auto. cnf. In this file is a unique uuid for the server. This is great, but if you are unaware of it, and simply copy the datadir to set up a slave, and do not remove this file, then you're in for some errors.
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With