Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL concepts: session vs connection

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

When talking about connecting to MySQL, we use connection terminology, connection pool, etc.

However in the 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.

like image 243
Xiaofeng Tang Avatar asked Jan 10 '12 02:01

Xiaofeng Tang


People also ask

What is difference between session and connection?

Literally : Connection is Physical Communication Channel and Session is a state of information exchange. A Connection may have multiple sessions . The connection is the physical communication channel between SQL Server and the application: the TCP socket, the named pipe, the shared memory region.

What is a MySQL session?

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.

What is database connection session?

A database connection is a session of work, opened by the program to communicate with a specific database server, in order to execute SQL statements as a specific user.

What is a session in SQL?

A SQL session is an occurrence of a user interacting with a relational database through the use of SQL commands. When a user initially connects to the database, a session is established.


1 Answers

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.

like image 141
newtover Avatar answered Oct 05 '22 21:10

newtover