sqlmapproject/sqlmap · error · OperationalError
server does not support selecting a database during the hand
Error message
server does not support selecting a database during the handshake
What it means
Error "server does not support selecting a database during the handshake" thrown in sqlmapproject/sqlmap.
Source
Thrown at extra/dbwire/mysql.py:331
if plugin == "caching_sha2_password":
auth_response = _scramble_sha2(password or "", salt)
else:
plugin = "mysql_native_password"
auth_response = _scramble_native(password or "", salt)
# capabilities are NEGOTIATED: each side advertises what it can do and only the intersection is in
# play. Sending a fixed set makes the client claim features a proxy/fork/older server never offered,
# which is how a handshake ends up desynchronized rather than cleanly refused.
if not (server_caps & _CLIENT_PROTOCOL_41):
raise OperationalError("server does not support the 4.1 protocol, which this client requires")
wanted = (_CLIENT_LONG_PASSWORD | _CLIENT_LONG_FLAG | _CLIENT_PROTOCOL_41 |
_CLIENT_TRANSACTIONS | _CLIENT_SECURE_CONNECTION | _CLIENT_PLUGIN_AUTH)
if database:
wanted |= _CLIENT_CONNECT_WITH_DB
flags = wanted & server_caps
flags |= _CLIENT_PROTOCOL_41 | _CLIENT_SECURE_CONNECTION # mandatory for the packets built below
if database and not (flags & _CLIENT_CONNECT_WITH_DB):
raise OperationalError("server does not support selecting a database during the handshake")
if not (flags & _CLIENT_PLUGIN_AUTH):
plugin = None # pre-4.1.1 style: no trailing plugin name in the handshake response
response = struct.pack("<I", flags) + struct.pack("<I", _MAX_PACKET) + struct.pack("<B", 45) + (b"\x00" * 23)
response += (user or "").encode("utf-8") + b"\x00"
response += struct.pack("<B", len(auth_response)) + auth_response
if database:
response += database.encode("utf-8") + b"\x00"
if plugin:
response += plugin.encode("ascii") + b"\x00"
_send_packet(sock, seq + 1, response)
_finish_auth(sock, password or "", plugin or "mysql_native_password", salt)
handshake_done(sock)
except (DatabaseError, InterfaceError):
_safe_close(sock)
raise
except Exception as ex:
_safe_close(sock)View on GitHub (pinned to 0a35b20e39)
When it happens
Trigger: Thrown at extra/dbwire/mysql.py:331 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26).
Data as JSON: /api/errors/21974836d5a094aa.
Report an issue: GitHub.