MySQL Protocols

X Protocol

Since MySQL 5.7.12 there is a new X Plugin that exposes a new communication protocol called X Protocol. X Protocol provides more flexible connectivity between client and server. It improves security by using trusted standards like TLS and SASL. It’s a new MySQL protocol that supports SQL and CRUD.New protocol for connection with the server has a new command utility for interactive work with the server, new NoSQL API with CRUD support, binding for Python, JavaScript, Node.js, Net, and Java, also with the ability of asynchronous query execution.For now, implemented features of the X protocol are prototypes for testing. Developers have great expectations for them and claim that in the upcoming updates the protocol will have API extensions and bindings with other languages. X protocol will be used for replication and sharding, as streaming protocol and more strict structuredness of queries simplify those tasks. It can also reduce the number of round trips by utilizing pipelining and thus enhance performance characteristics.

MySQL Client/Server Protocol

MySQL Client/Server protocol is used in server operations to create, read, interpret, and send protocol packets between MySQL Clients and a MySQL Server. It is implemented by connectors, MySQL Proxy and communication between master and slave replication servers.The protocol supports the following features:
  • Transparent encryption using SSL
  • Transparent compression
  • Command phase that is used to accept commands from the server and execute them
  • Connection phase that performs SSL communication setup and authentication between the client and the server
Here is a short review on how the protocol functions:
  1. Auth-phase:
  • Client connects to the server
  • Server sends a handshake packet to the client
  • Client sends an auth-packet
  • Server allows the transaction or retrieves an error message
  1. Query-phase
  • Client sends a COM_* packet
  • Server sends one of the following: OK, Error, EOF (End of File) message or a result-set.