Be more specific on detecting mysql socket #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous code enumerates lists both listening and connected sockets. The output of listening (-l) is enough for the intended purpose. Optimizing this.
Further on, it matches on the first socket which in my case was mysqlx.sock which leads later to a protocol error. More specific search string resolves this.
As on this situation:
netstat -axn | grep mysql
unix 2 [ ACC ] STREAM LISTENING 1934165 /var/run/mysqld/mysqlx.sock
unix 2 [ ACC ] STREAM LISTENING 1934169 /var/run/mysqld/mysqld.sock
unix 3 [ ] STREAM CONNECTED 1934197 /var/run/mysqld/mysqld.sock
[...]
we had
netstat -axn | grep -m1 mysq
unix 2 [ ACC ] STREAM LISTENING 1934165 /var/run/mysqld/mysqlx.sock
and error
ERROR 2007 (HY000): Protocol mismatch; server version = 11, client version = 10
After the fix it finds the right socket:
netstat -lxn | grep -m1 mysqld.sock
unix 2 [ ACC ] STREAM LISTENING 1934169 /var/run/mysqld/mysqld.sock