2

I'm trying to create a diagram for some architecture I'm working on. While doing so I was wondering what type of communication is actually happening between PHP and a MySQL Database. I've used it countless times but never really wondered about it. How does the PHP send its queries if the MySQL Database is on another Server. The PHP Layer establishes the connection but what is happening when it actually queries the Database? Does it send the Query as a plain text? And what does it actually receive, also plain text?

best regards

1 Answer 1

3

The communication aspect of SQL is often carried by a driver (ODBC and such), so you don't have to worry about it.

MySQL uses its own protocol. There is a handshake phase, authentication, and you then send a prepared statement to the server via COM_STMT_PREPARE, and ask the server to execute it via COM_STMT_EXECUTE.

You might want to get a look on MySQL internals manual :

https://dev.mysql.com/doc/internals/en/client-server-protocol.html

Sign up to request clarification or add additional context in comments.

2 Comments

so basically what I got out of the link is that, the MySQL driver uses its own protocol therefore sends/receives packages when communicating and encodes/decodes them when sent/received. Is that some kind of socket communication?
Yeah, you got it. Somebody else could confirm it further, but it seems like it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.