- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I determine the connection method used by a MySQL Client?
To determine the connection method that is used by MySQL connection, the below command can be used −
netstat −ln | grep 'mysql'
On Unix, MySQL programs treat the host name ‘localhost’ in a special manner. Hence, it behaves differently than what is expected of it.
Type of Connection
To know the type of connection from within the mysql CLI, the below command can be used −
mysql> \s
Output −
Connection: 127.0.0.1 via TCP/IP (or) Connection: Localhost via UNIX socket
TCP/IP connection to the local server
To ensure that the client makes a TCP/IP connection to the local server, the --host or -h can be used. This will specify the host name value as 127.0.0.1, or the IP address or name of the local server. The connection protocol can also be specified explicitly, for localhost as well, with the help of the --protocol=TCP option. Let us see an example −
shell> mysql --host=127.0.0.1 shell> mysql --protocol=TCP
The --protocol={TCP|SOCKET|PIPE|MEMORY} option specifies explicitly that a certain protocol has to be used to connect to the server
Connections on Unix to localhost
Connections on Unix to localhost are made with the help of a Unix socket file by default. Let us see how this done using the below command −
shell> mysql --host=localhost
To force a TCP/IP connection to be used, a --protocol option can be specified. Let us see how it can be done −
shell> mysql --host=localhost --protocol=TCP
Some of the protocol types have been listed below −
TCP − TCP/IP connection to connect to a local or remote server. It is available on all platforms.
SOCKET − It is the Unix socket file connection to local server. It is available on Unix only.
PIPE − It is the named-pipe connection to local or remote server. It is available on windows only.
MEMORY − It is the shared-memory connection to local server. It is available on windows only.
- Related Articles
- How can I determine the position of a Toplevel in Tkinter?
- In MySQL, why a client cannot use a user-defined variable defined by another client?
- How to determine database type (name) for a given JDBC connection?
- How can I set a MySQL database to use MyISAM by default?
- How Can we permanently define user-defined variable for a client in MySQL?
- How to determine the version of the C++ standard used by the compiler?
- How can we take a backup of the single database by using mysqldump client program?
- How can we take a backup of all the databases by using mysqldump client program?
- How can I make a browser to browser (peer to peer) connection in HTML?
- How can we take a backup of multiple databases by using mysqldump client program?
- How do you determine which backend is being used by matplotlib?
- Which PHP function is used to disconnect from MySQL database connection?
- How can I get the information about a particular column of a table by MySQL DESCRIBE statement?
- How can I stop a running MySQL query?
- How can I stop running a MySQL query?
