Mysql – slave thesql configuration is not stored

master-slave-replicationMySQLssh

EDIT
It seems that the problem is with my SSH connection, so I created a different question on serverfault. From what I understand so far, it that this problem is caused from the fact that the port forwarding is not established properly.

Original question
I am trying to create a master-slave sync between two Mysql instances. After a lot of work, I at least have two running servers (since I had so many problems that most of the times I was breaking something).
Now, on my slave my.cnf file I have

server-id = 155
log_bin =
/var/log/mysql/mysql-bin.log
master-host = 127.0.0.1
master-user =
masterUser
master-password = masterpassword
master-port = 3336
(I am using port forwarding, so that why I use 127.0.0.1 as host)

The problem is that when I ask for the slave's id I get 0

mysqld --help --verbose |grep server-id

replicate-same-server-id FALSE
server-id 0

and

mysql> SHOW VARIABLES LIKE 'server_id';

+—————+——-+
| Variable_name | Value |
+—————+——-+
| server_id | 0 |
+—————+——-+

The file I am using is the proper file, since when I added this

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

the result of mysqld --help --verbose |grep character-set-server
changed from

character-set-server latin1

to

character-set-server utf8

Thanks in advance

Best Answer

A few things to check:

  • Have you restarted the MySQL instance after setting the server-id variable in my.cnf? (Obvious, I know, but I have to ask!)
  • In which section of the my.cnf file have you added this variable? The [mysqld] section would be an appropriate place for it, I think.
  • Do you have any other .cnf files that might overwrite your setting? Assuming Linux, a command such as mysqld --help --verbose | head -n 20 should give you some output which includes the files where mysqld is looking for default settings.