Asterisk SQL lookup dies on virtual machine

To validate callers we do a MYSQL lookup in inbound routes. Today it stopped working for no apparent reason and all calls started dropping at the line below.

exten => _X.,n,MYSQL(Connect connid remote-IP DBuser DBpasswd SQL-DB)

At first we thought the remote IP was the problem but
# mysql -u DBuser -p -h remote-IP
+ password
continued to work which means SQL connections outside Asterisk worked fine while any SQL calls in Asterisk failed. Switching the SQL lookup to localhost (we have old test data local) did not work. Restarting Asterisk did not fix the issue either. Only SQL restart worked.

This is a mature system. 64-bit FreePBX Distro 10.13.66-17 server with 2GB RAM
and Asterisk 13.12.1 (previously Asterisk 11)
Any ideas?

Just so we’re clear - you restarted the MySQL Server and the remote connections from Asterisk were then OK?

Spooky.

I did so many things trying to resolve this that it’s hard to tell what got it working again in the end.
I know fwconsole restart did not resolve it and changing the request to localhost did not fix it either.

At some point I did a service mysqld restart and continued tinkering. Then I noticed a couple of minutes later that it was working again. So I am just guessing that this fixed it but I don’t remember doing anything significant afterwards.

The weird thing is that all this time I was able to make the same remote connection via
`# mysql -u DBuser -p -h remote-IP’
when the same remote connection failed from Asterisk.