cfengine: fix opportunistic linking with mysql and postgres

Fixes #24448.