Remote mysql connection fails with accessed denied exactly every other attempt On my development machine remotely connecting to Mysql i will get an access denied error every other attempt. What's odd is when it does fail like this it doesn't write to the mysql error log on the server like it does when there is a "real" access denied.

I came across this when writing a python program at first i thought it was the mysql python connector, so i switched to mysqldb same problem, and then i just tried straight from the CLI and the same issue. It's exactly every other attempt.

[~]$ mysql -h servername -u user -p db -e "SHOW VARIABLES LIKE '%version%'"
Enter password: 
ERROR 1045 (28000): Access denied for user 'user'@'ip' (using password: YES)

[~]$ mysql -h servername -u user -p db -e "SHOW VARIABLES LIKE '%version%'"
Enter password: 
+-------------------------+-------------------------+
| Variable_name           | Value                   |
+-------------------------+-------------------------+
| innodb_version          | 5.7.19                  |
| protocol_version        | 10                      |
| slave_type_conversions  |                         |
| tls_version             | TLSv1,TLSv1.1           |
| version                 | 5.7.19-0ubuntu0.16.04.1 |
| version_comment         | (Ubuntu)                |
| version_compile_machine | x86_64                  |
| version_compile_os      | Linux                   |
+-------------------------+-------------------------+

[~]$ mysql -h servername -u user -p db -e "SHOW VARIABLES LIKE '%version%'"
Enter password: 
ERROR 1045 (28000): Access denied for user 'user'@'ip' (using password: YES)

[~]$ mysql -h servername -u user -p db -e "SHOW VARIABLES LIKE '%version%'"
Enter password: 
+-------------------------+-------------------------+
| Variable_name           | Value                   |
+-------------------------+-------------------------+
| innodb_version          | 5.7.19                  |
| protocol_version        | 10                      |
| slave_type_conversions  |                         |
| tls_version             | TLSv1,TLSv1.1           |
| version                 | 5.7.19-0ubuntu0.16.04.1 |
| version_comment         | (Ubuntu)                |
| version_compile_machine | x86_64                  |
| version_compile_os      | Linux                   |
+-------------------------+-------------------------+


It's to the point that i had to hack my program to just always try twice and only raise an exception if there were two back to back failures. That's hacky and bad. I have to be messing something obvious its too reproducible.
Had to use ip of host instead of hostname. Problem was dns related but the way that it manifested still confuses me.