Aung Thet
Aung Thet

Reputation: 3640

Can't set mysql wait_timeout in ubuntu at path /etc/my.cnf

I am facing an error of "Broken Pipe" in mysql database connection. That error appear when the server isn't accessed by anyone till 8 hours, the connection is timeout and can't connect to mysql database server. I find and try many way for that error. In that, setting wait_timeout variable from 28800 to 86400 (means 8 hours to 24 hours). In that, I had copied my.cnf file from etc/mysql/my.cnf to etc/my.cnf to set user specification value and add variable like :

[mysql]
wait_timeout = 86400
interactive_timeout = 86400

But when I login to mysql with command mysql -u root -p, the following error is shown: mysql: unknown variable 'wait_timeout=86400'

How can I set wait_timeout variable in ubuntu linux server. Pls

Upvotes: 4

Views: 7626

Answers (2)

site80443
site80443

Reputation: 301

Writing this in the hope that it will help some of you stuck at the same obviously strange issue - why won't mysql pick up the option!

Sometimes it is more of an OS/distribution issue. On Ubuntu 18.04 (at least on AWS EC2). I set the value of wait_timeout = 600 in /etc/mysql/mysql.conf.d/mysqld.cnf which seems to be right place to set server-level permanent options and restarted mysql with

# systemctl restart mysql.service

This did not work.

Then I tried # systemctl stop mysql.service && systemctl start mysql.service

This did not work either.

After much searching and frustration I casually tried

service mysql restart

This worked.

I hope someone else can clarify why this way of restarting mysql picks up the changed cnf options while the earlier does not, especially for wait_timeout.

Upvotes: 0

Sunil Goli
Sunil Goli

Reputation: 459

Try placing

wait_timeout = 86400
interactive_timeout = 86400

under [mysqld] ie,

[mysqld]
wait_timeout = 86400
interactive_timeout = 86400

and restart mysql server.

Upvotes: 11

Related Questions