Controlling Sessions

The following walkthrough describes how to control user sessions. You will learn how to view session information, stop query execution and disconnect sessions.

Prerequisites

In order to complete this walkthrough, you will need to use access MySQL server 5.0.13 or higher.

Starting Session

Execute the following query.

SELECT * FROM 
demobase.emp e1,
demobase.emp e2,
demobase.emp e3,
demobase.emp e4,
demobase.emp e5

To do this, perform the following steps:

  1. Open an SQL editor by clicking the New SQL button on the Standard toolbar.
  2. Type or paste this code to the document.
  3. Execute the document by clicking the button on the SQL toolbar.

Managing Sessions

Viewing Session Information

Launch another instance of the dbForge Studio for MySQL (don’t close the previous one) and open the Session Manager window in it. To call the Session Manager, select Session Manager on the Database menu.

If you have the global PROCESS privilege, you will see all user sessions for the current connection. Otherwise, you will see only your own sessions.

Click on the Host column caption to order all data by host. Find your connections (from your host). Then click on the connection which has Query in the Command column. In the bottom part of the Session Manager you can see the text of the executing queries. Find your connection executing the query above.

Killing Session and Query

Right-click the session with our query and choose Kill Query on the shortcut menu. Click Yes in the appeared dialog. Then switch back to the previous instance of dbForge Studio for MySQL and scroll down the data grid. You will get a message Query execution was interrupted.

Switch to the dbForge Studio for MySQL with Session Manager open. Again right-click the session and choose Kill Session on the shortcut menu. Switch back to the previous instance of dbForge Studio for MySQL and click the Refresh button on the Database Explorer toolbar. You will get a message Lost connection during query.

If you have the global SUPER privilege you can kill queries and sessions of all users, otherwise, only your own sessions and queries.