2

When I start my MySQL client from the command-line, I do the following:

$ mysql -u root -p -h 127.0.0.1 --init-command="SET SESSION wait_timeout=300"

I set the session wait_timeout to 300 seconds for security purposes. If there is no database activity for 5 minutes, I want the connection to be killed so that it is not actively left open for long periods of time which is a security risk.

However, I really prefer using the Mac desktop application SequelPro to access the database instead of the command-line shell. It's my bread-and-butter. I absolutely love it. Here's what it looks like when I open a DB connection in SequelPro:

enter image description here

So how can I give SequelPro the same `--init-common argument I gave on the command-line above? Or is there any other way for me to achieve the security goal I'm trying for?

Saqib Ali
  • 11,931
  • 41
  • 133
  • 272

1 Answers1

4

If you want to make this global setting for everyone connecting from any tool. You add this to the configuration file, my.cnf (if you're running MySQL on Unix-based OSs) or my.ini (if you're running MySQL on Windows-based OSs).

This is from MySQL documentation about wait_timeout

The number of seconds the server waits for activity on a noninteractive connection before closing it.

On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()). See also interactive_timeout.

So, set this global parameter in [mysqld] section of your configuration file to keep your security in check.

[mysqld]
interactive_timeout=300
wait_timeout=300
MontyPython
  • 2,906
  • 11
  • 37
  • 58