I've been trying to set up two databases as master & slave.
I followed the famous guide here: https://dev.mysql.com/doc/refman/5.1/en/replication-howto-existingdata.html
But no luck on my slave server,
The issue I'm having is setting the server-id
variable.
No matter where I define it (I looked into all the possible cnf files that might allow me to define the variable)
I tried to define it like so:
[mysqld]
server-id = 2
I also tried setting it by using SET GLOBAL server_id but obviously, it didn't save the setting.
when I do:
SHOW VARIABLES LIKE 'server_id'
It returns
server_id 0
Among the cnf files I've looked into are:
etc/mysql/mysql.conf.d/mysqld.cnf
etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf
etc/mysql/conf.d/mysql.cnf
etc/mysql/debian.cnf
etc/mysql/mysql.cnf
usr/my.cnf
usr/my-new.cnf
usr/etc/my.cnf
My MySQL server is running on Ubuntu. And if it matters, I start it by typing:
service mysql start
I'd love to know where else I could look to fix this issue. Thanks a bunch!
Additional Notes:
MySQL Ignoring the global conf file
I received this warning a couple of times and it disappeared when I returned the chmod to 644 on the etc/mysql folder, although every thing stated above was attempted using both 644 and 777 permissions, with 644 the warning disappears.
System variables can be set at server startup using options on the command line or in an option file. Most of them can be changed dynamically while the server is running by means of the SET statement, which enables you to modify operation of the server without having to stop and restart it.
This server ID is used to identify individual servers within the replication topology, and must be a positive integer between 1 and (232)−1. The default server_id value from MySQL 8.0 is 1.
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
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.
I know it's to late, but for those who will make the mistake. It's server_id and not server-id:
[mysqld]
server_id = 2
For me it worked by renaming the from /etc/mysql/conf.d/my.cnf to /etc/mysql/conf.d/my.ini
I'm not sure of the exact reason for that (feel free to edit this answer and add to it).
I tried out various combinations:
server-id
and server_id
[mysql]
and [mysqld]
my.cnf
, mysqld.cnf
, mysql.cnf
, my.ini
You can keep trying various combinations out of the above options, it should definitely work. :)
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