Running show variables like 'server%'
shows server_id
as variable name.
But in my.cnf
, there's an entry for server-id
(although commented out)
Is there any differece between the them?
They are same but as it is stated in this post , if your server-id is not changed by setting my.cfg
you can try setting it by underscore
[mysqld]
server_id = 2
MySQL
4.2.9 Using Options to Set Program Variables :
...
If you like, underscores in a variable name can be specified as dashes. The following option groups are equivalent. Both set the size of the server's key buffer to 512MB:
[mysqld] key_buffer_size=512M [mysqld] key-buffer-size=512M
...
MariaDB
Server System Variables and mysqld Options :
...
By convention, server variables have usually been specified with an underscore in the configuration files, and a dash on the command line. You can however specify underscores as dashes - they are interchangeable.
...
Test MySQL
File: my.cnf
[mysqld]
.
.
.
server_id=987
.
.
.
Command-Line:
$ mysql --execute="SELECT VERSION(), @@server_id"
+-----------+-------------+
| VERSION() | @@server_id |
+-----------+-------------+
| 8.0.13 | 987 |
+-----------+-------------+
File: my.cnf
[mysqld]
.
.
.
server-id=321
.
.
.
Command-Line:
$ sudo systemctl restart mysql
$ mysql --execute="SELECT VERSION(), @@server_id"
+-----------+-------------+
| VERSION() | @@server_id |
+-----------+-------------+
| 8.0.13 | 321 |
+-----------+-------------+
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.