All we need is an easy explanation of the problem, so here it is.
How can I find out which Transport Protocol MySQL is using? I know how I can change it but I don’t know how to show the current one.
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
There are two passive ways to find that out
- Connection Status
- MySQL Prompt
If you execute the status command (
you get this output
MySQL://localhost/root/mysqld.sock/(none)> \s -------------- mysql Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using EditLine wrapper Connection id: 3 Current database: Current user: [email protected] SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.7.26 MySQL Community Server (GPL) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: latin1 Conn. characterset: latin1 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 10 min 57 sec Threads: 1 Questions: 24 Slow queries: 0 Opens: 109 Flush tables: 1 Open tables: 28 Queries per second avg: 0.036 -------------- MySQL://localhost/root/mysqld.sock/(none)>
Protocol version, you see how I am connected:
Protocol version: 10 Connection: Localhost via UNIX socket
Another method would be to look at your MySQL prompt, provided you configured the prompt display. Please note my current prompt:
I have it set in
.my.cnf under the
[mysql] group header
[mysql] prompt="MySQL://\h/\u/\p/\d> "
\h echoes the host address and
\p echoes the port number in use. in my case, since it echoes
mysqld.sock , it is not using TCP/IP. If it were using TCP/IP, it should echo
If you want to try connect with TCP/IP, you have to use –protocol as you mentioned:
#> mysql -h127.0.0.1 --protocol=tcp -uroot -p
I don’t think there is a variable for that.
As it makes basically no different, if you use on a local machine (names pipes windows only / Sockets linux only ) or tcp/ip.
When you try to connect from another machine you can use only tcp/ip
When you connect to a local host with
-h localhost then the client will first try to use names pipes/sockets and when that fails it will try tcp/ip.
If you connect with
-h 127.0.0.1 the client will use only tcp/ip
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂