How to set MySQL "wait_timeout" option on Ubuntu

I was trying upload a large database on Ubuntu that kept failing because of connection timeout problem, so I had to take the following steps:

1. To make it easier to find the right .cnf file, create a symbolic link:


ln -s /etc/mysql/mysql.conf.d/mysqld.cnf /etc/my.cnf

2. Paste with nano /etc/my.cnf


[mysqld]
wait_timeout = 31536000
interactive_timeout = 31536000

3. systemctl restart mysql

4. Verify with:

mysql
SELECT @@global.wait_timeout, @@session.wait_timeout;

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.