+4 votes
in Databases by (54.1k points)

I am trying to optimize the tables of my database from PHPMYADMIN, but It gives the following error: "MySQL error 2006: mysql server has gone away". How can I fix this error?

1 Answer

+1 vote
by (233k points)
selected by
Best answer

It may be possible that your database is very heavy (i.e. many records) and the value of variable wait_time is very low in the MySQL configuration file. Although the default value of wait_time is 28800 seconds, do not set such high value as a bad code can cause issues. Here are the steps:

  • If you have root access, open my.cnf (MySQL) or mariadb.cnf (MariaDB) in an editor.

# vi /etc/mysql/mariadb.cnf

  • Update the following variables.


  • Restart MySQL

# systemctl restart mariadb.service


# systemctl restart mysql.service

If you still get the same error, increase the value of wait_timeout.