Failure during database access!

docna wrote on Friday, December 19, 2014:

Hi,
I have been using open-emr for my practice since september of this year, learning its ways over this time. Last week I noticed that when I tried to save something on a patient sometimes I would get a message that said something about “make sure that MySQL is running” (not sure of the exact wording) but a refresh of the page would usally bring the page again (sometimes without saving the information).
But since this week, I have been getting, after login, this Message: Failure during database access! Check server error log.
I went to the server and the error log of the openemr directory has a date of October so I figured that there was no useful info there.
But But the error log at Interfase/login is dated to December 15 so I thing this may be relevant.
So these are the last lines on that log:

[15-Dec-2014 14:56:40 America/New_York] PHP Warning: mysql_pconnect() [function.mysql-pconnect]: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) in /home/doctorna/public_html/openemr/library/adodb/drivers/adodb-mysql.inc.php on line 383
[15-Dec-2014 14:56:40 America/New_York] PHP Warning: reset() expects parameter 1 to be array, boolean given in /home/doctorna/public_html/openemr/library/sql.inc on line 72
[15-Dec-2014 14:56:40 America/New_York] PHP Warning: mysql_error() expects parameter 1 to be resource, boolean given in /home/doctorna/public_html/openemr/library/sql.inc on line 494
[15-Dec-2014 14:56:40 America/New_York] PHP Fatal error: Call to undefined function text() in /home/doctorna/public_html/openemr/library/sql.inc on line 549

I don’t understand what to do with this information and how can I gain access to my patient’s database again. I hope someone could help me with this.

Thank you in advance for your help.
E. Navarro

fsgl wrote on Friday, December 19, 2014:

Explanation of fatal error, under “PHP Errors”.

yehster wrote on Saturday, December 20, 2014:

Please provide more details about your environment.

It looks like you using a web host rather than your own hardware, which may make troubleshooting more difficult.

docna wrote on Monday, December 22, 2014:

Thanks for your help, fsgl. I looked for a file named “PHP Errors” on the site, first manually, then with the find feature of the file manager and couldn’t find a file with that name. Is it on a named folder that you can direct me to?
Thanks again.
ENavarro

docna wrote on Monday, December 22, 2014:

Thanks for replying, Kevin.
Yes I have OpenEMR set on a web host thinking in accessing it on two different computers that were not on the same network at the clinic. But I am the only user and if there would be no way of making it work from the host I could install it on one of the computers and work from there, if I could recover the information that is already in the database.
I don’t know what details I can provide you but I will do my best to do if you tell me what details you need. I can access the directories and files on the server and there is a option on the site to check and repair MySQL databases. I used the check option and I am attaching the resulting page. I didn’t use the repair option yet.
Hope you can help me and I thank you in advance.
Efren

fsgl wrote on Monday, December 22, 2014:

Try the solutions from the above cited web article, specifically under the 3rd section “Database-Related Errors” & 4th section “PHP Errors”.

Rachel Andrew is excellent explaining errors that you are encountering.

yehster wrote on Monday, December 22, 2014:

The DBcheck file you attached shows that there is corruption of your database.

One of the key tables that handles user login is reported as not existing

[doctorna_openemr.users_secure] Error: Table ‘doctorna_openemr.users_secure’ doesn’t exist
[doctorna_openemr.users_secure] status: Operation failed

Again, because you are using a “hosted” environment, it’s hard to know how to best to recover/repair your database. The option that your site provides to “repair” might work, but that is just speculation.

docna wrote on Tuesday, December 23, 2014:

Oh, I see. I went and read the article. Unfortunately there is no php error log on the website and when I tried to modify the .htaccess file to make php to create one the site would not load at all. I submitted a ticket to the host provider to see I they can log the errors from php so I could see what is wrong.
Also the database related errors section addresses errors that happen when you create the database. Mine was working normally for months and then stopped loading.
Let’s hope that I can access the php errors log and find something to solve this problem.
Thanks again for your suggestion.

docna wrote on Tuesday, December 23, 2014:

Well, I tried the repair option on the website but it didn’t work.
It is likely that this is the login problem. I went to phpMYadmin on the website and confirmed that this table (users.secure) does not exist. On the users table, on the password column says nolongerused. Same thing on the receptionist account.
So, how can this table can be recreated? Or, what can I try?
I have backups of the database from a date before it got corrupted but they are in a sql.gz format and I don’t know if they are usable. On the cPanel of the host it says that they can restore the database but they will likely replace all the tables erasing recent patient data.
Any suggestion will be greatly appreciated.

yehster wrote on Tuesday, December 23, 2014:

The SQL commands to create tables, including users_secure are available from the source code.

.gz format just means that the file is compressed. gunzip should turn your .sql.gz into just plain .sql which will be human readable

However, if you restore the backup, there might be notes/records that were changed between the time of the backup and the time the corruption occurred, so trying to restore to a local instance of OpenEMR rather than to the webhosted copy is recommended.

If you were my customer, the approach I would take would be to export the current data on the webserver and then merge it with the most recent backup. Using mysqldump if your webhost provides access that, or PHPMyAdmin as an alternative for the export process.

fsgl wrote on Tuesday, December 23, 2014:

Efren,

All these difficulties with your hosted OpenEMR may be a blessing in disguise. With a hosting service, the user has much less control & you have to take their word for securing your Protected Health Information.

If your clinic is in New York, the state has confidentiality laws far more stringent than HIPAA. Mike Semel’s article should be an eye opener. Bear in mind, should a security breach occur; governmental agencies will go mainly after you, not the host.

I understand that cPanel does not afford the ability of using the command line. If the zip .sql file is the result of OpenEMR’s backup utility, it gets around the problem of running a SQL dump.

The next step would a decision how best to merge data from the hosting website with that in localhost.

docna wrote on Tuesday, December 23, 2014:

So it seems that it is preferable to have the database in a local computer instead of a web hosting site. I didn’t understand that when I first set it up.
So now I will be looking to a way for merging the remote data to a local installation.
I am using a Connecticut web hosting company but my practice is in Mexico.
I don’t see any other users on the users database which I can access but I don’t know if this would be a sure way to tell if there was a breach. Still there are no SS number on it but of course there is health information about a handful of patients (Most are still on the older system).
I’m not sure if I used the OpenEMR backup utility (most likely) or the website database backup feature. Will try to find out later at the office.
Thanks again for your comments and information.

docna wrote on Tuesday, December 23, 2014:

I was thinking if it was possible to just restore the missing table from the backup. I don’t know much about this but maybe that users_secure table is rather static and restoring just that table allows me to log in again. Then, having full access again transfer it to a local computer. Can this be done?
Thanks again for your help and comments, Kevin.

fsgl wrote on Tuesday, December 23, 2014:

Physicians the world over are held to very high ethical standards, HIPAA notwithstanding. None of us would want our EHR’s hacked.

Here is a webpage about database merger. There is also a link to the MySQL documentation page about replication, which seems very complex. If you find it to be the case as well, I would suggest enlisting help from one of the OpenEMR certified contributors.

I wish you the best of luck & Feliz Navidad.

docna wrote on Wednesday, December 31, 2014:

¡Gracias!
Back from the Holidays. I will review the information on the page that you suggested and start from there.
Thanks for your help and ¡Feliz Año Nuevo!