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.
The syntax is as follows
SELECT@@ server_id
As an alternate, you can use SHOW VARIABLES command.
The syntax is as follows
SHOW VARIABLES LIKE ‘server_id’;
Case 1The query is as follows
mysql> SELECT @@server_id as SERVER_ID;
The following is the output
+-----------+ | SERVER_ID | +-----------+ | 1 | +-----------+ 1 row in set (0.00 sec)
Case 2The query is as follows
mysql> show variables like 'server_id';
The following is the output
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 1 | +---------------+-------+ 1 row in set (0.01 sec)