try to understand mysql concepts: session v.s. con

2020-05-19 05:36发布

问题:

I'm a bit confused by mysql concepts: session vs connection.

When we are talking about connecting to mysql. We use connection terminology, as well as connection pool and etc.

However let's go to mysql online doc: http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html. It talks about session variables.

They are quite similar. How to distinguish them?

Thanks in advance.

回答1:

A session is just a result of a successful connection. Any MySQL client requires some connection settings to establish a connection and after the connection has been established it acquires a connection id (thread id) and some context which is called session.