We are getting following error
mysql> show tables;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 12
Current database: openmrs
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111)
ERROR:
Can’t connect to the server
Restarting mysql or the server itself hasn’t helped. mysql starts in force mode but as readonly.
How do I check bahmni connection credentials? Bahmni does not run at all. OpenMRS able to login but Administration->Location Hierarchy gives JDBConnection error.
This will not help as this is not related to the user id pwd issue. I am able to login to mysql. It throws error after login to mysql from command prompt.
The MySQL server has gone away (error 2006) has two main causes and solutions:
Server timed out and closed the connection. To fix, check that wait_timeout mysql variable in your my.cnf configuration file is large enough.
Server dropped an incorrect or too large packet. If mysqld gets a packet that is too large or incorrect, it assumes that something has gone wrong with the client and closes the connection.
To fix, you can increase the maximal packet size limit max_allowed_packet in my.cnf file, eg. set max_allowed_packet = 128M, then restart your MySQL server: sudo /etc/init.d/mysql restart
Checked both log files - /var/log/mysqld.log and var/log/openmrs/openmrs.log did not have any relevant information. Ensured that the last successful backup gets restored on another machine.
Forced restart of mySQL - Restarted mySQL using
innodb_force_recovery = 4.
This restarted the mySQL server in Read Only mode which only confirmed that there is no other issue (uid, pwd, bahmni, openmrs etc.) other than some problem with the database itself.
mySQL check From CentOS command Prompt as mentioned here:
mysqlcheck -uuid -ppwd openmrs
This showed OK for most tables till location_tag where connection got terminated indicating that this table has some issue. When tried mysqlcheck on location_tag_map it showed Ok.
So used
with no success ie connection got terminated. Tried
Alter table location_tag ENGINE = InnoDB;
which did not help either ie connection got terminated.
Restore specific table - Due to lack of repair from the last successful backup which was restored on another machine extracted location_tag table using
Restored it using
mysql -uuid -ppwd openmrs < location_tag.sql
This also failed due to connection terminated.
Restore last successful backup - Using innodb_force_recovery = 4 started mysql and dropped openmrs database. Removed innodb_force_recovery = 4 and restarted mysql. Then restored the last successful backup.
This got successfully restored but need further investigation on why the repair options failed.