Try something like this:
UPDATE `creature_template` SET `rank` = 2 WHERE (`entry` = 5291);
Using ` at the start and end of rank should make HeidiSQL recognize it as a column name and not as a command.
Note that ` is a special character and not an apostrophe like ' (I know, the difference is hard to see, but if you use an apostrophe, heidisql will recognize the text as a string), an easy way to have it at the ready if your keyboard doesn't have it is to copy and paste it in a document and bring it up whenever you need it
It looks like this: