Cannot remove or reinstall broken openemr

rdh61 wrote on Saturday, February 04, 2012:

Hi,
While attempting to upgrade from openemr 3.2.0-1 to 4.1.0-1 on ubuntu 10.04, I managed to break 4.1.0-1. Now I can neither remove or reinstall it. The error message tells me that: "cannot remove/upgrade the package because openemr is not installed at /var/www.
How can I resolve this?
Many thanks.

rdh61 wrote on Saturday, February 04, 2012:

Update.

I managed to uninstall openemr 4.1.0-1 and reinstall it. During installation, I was told that it found and successfully connected to my pre-existing openemr database. However, when I opened openemr, I couldn’t see any of my patient records.

Then I tried to restore a backup made with version 3.2.1-1 but I got an error message: something about some files not existing.

I then uninstalled version 4.1.0-1 again and tried to reinstall 3.2.1-1, but I got another error: it cannot install because an openemr database already exists!

It’s a fine mess. What can I do to get out of it?

Thank you.

bradymiller wrote on Saturday, February 04, 2012:

Hi,

If you got the above error(in first post), then nothing should of happened and it should of aborted the upgrade altogether; this is because it did not find the /var/www/openemr directory. Did you try OpenEMR after this error; if so, it should of simply taken you to your original 3.2 version? Or was this after doing a successful 4.1 upgrade?

Best to clearly show what steps you have done.

Also, can you copy/paste the following files here:
/etc/openemr/openemr.conf
/var/log/openemr/install

And, do you have any /tmp/openemr-tmp/ directories; if so, then list them here?

And, what do you see when type following at command line:
sudo dpkg -s openemr

-brady

rdh61 wrote on Saturday, February 04, 2012:

Thanks for your help.

The first step was this that of an apparently successful upgrade. During installation, I was told that it found and successfully connected to my pre-existing openemr database. However, when I opened openemr, I couldn’t see any of my patient records. I then tried to uninstall, but was met with the error message “cannot remove the package because openemr is not installed at /var/www”. There might have been some intermediate actions, but I can’t remember what if any.

/etc/openemr/openemr.conf :

#Optional settings
#(currently empty, plan to use in subsequent versions of OpenEMR)

#Installation settings
# (DO NOT EDIT below!!!)
process=complete

/var/log/openemr/install :

Sat Feb  4 09:58:37 CET 2012: MySQL ‘openemr’ database already exists
Sat Feb  4 09:58:37 CET 2012: EXITING……….
Sat Feb  4 10:00:13 CET 2012: MySQL ‘openemr’ database already exists
Sat Feb  4 10:00:13 CET 2012: EXITING……….
Sat Feb  4 10:03:09 CET 2012: Configuring package…
Sat Feb  4 10:03:09 CET 2012: Installing OpenEMR
Sat Feb  4 10:03:21 CET 2012: Passed the mysql check loop
Sat Feb  4 10:03:45 CET 2012: Will install OpenEMR, however will not automatically configure OpenEMR. (MySQL database already exists)
Sat Feb  4 10:03:52 CET 2012: Will install OpenEMR, however will not automatically configure OpenEMR. (MySQL user already exists)
Sat Feb  4 10:03:52 CET 2012: Installing OpenEMR …
Sat Feb  4 10:03:52 CET 2012: Configuring Apache for OpenEMR
Sat Feb  4 10:04:04 CET 2012: Added entries to apache configuration to secure directories with patient information.
Sat Feb  4 10:04:04 CET 2012: Placed backup of your original apache configuration file to /etc/apache2/httpd.conf.BAK
Sat Feb  4 10:04:04 CET 2012: Done configuring Apache
Sat Feb  4 10:04:04 CET 2012: Configuring PHP for OpenEMR
Sat Feb  4 10:04:05 CET 2012: Your PHP configuration is perfect for OpenEMR.
Sat Feb  4 10:04:05 CET 2012: Done configuring PHP
Sat Feb  4 10:04:05 CET 2012: Restarting Apache service
* Restarting web server apache2
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
… waiting …apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
   …done.
Sat Feb  4 10:04:25 CET 2012: You can now configure OpenEMR by browsing to:
Sat Feb  4 10:04:25 CET 2012: http://localhost/openemr
Sat Feb  4 10:04:25 CET 2012: See the openemr man page for further instructions:
Sat Feb  4 10:04:25 CET 2012: type ‘man openemr’ at command line
Sat Feb  4 10:44:06 CET 2012: You have chosen to not install the OpenEMR package.
Sat Feb  4 10:44:06 CET 2012: EXITING……….
Sat Feb  4 10:45:15 CET 2012: Unable to upgrade from … version package with raw method, so can not upgrade the OpenEMR Package.
Sat Feb  4 10:45:15 CET 2012: EXITING……….

No /tmp/openemr-tmp/ directories are present.

sudo dpkg -s openemr  gives:

Package: openemr
Status: install ok not-installed
Priority: optional
Section: web

bradymiller wrote on Saturday, February 04, 2012:

Hi,
if you go to openemr in your browser, what happens?
-brady

bradymiller wrote on Saturday, February 04, 2012:

Hi,
It appears you did following maybe:
1) upgrade
2) something wrong with upgrade, so removed package, which will delete everything (and I mean everything). However, I bet your old database is still there.
3) When installed 4.1.0 package, the database was there, so it didn’t configure it for you.
4) The hope is that you can now:

  • configure new openemr install to install into a new database
  • then point the sites/default/sqlconf.php config into the old database
  • then may need to run the sql_upgrade.php script and acl_upgrade.php script to upgrade the old database from 3.2.0 to new

What will help now is if you have anything at /var/www/openemr and then what happens when you go to openemr in your browser. Also, not sure if openemr package is installed (confused by install ok not-installed), and am wondering if there is any other output after that.

-brady

rdh61 wrote on Saturday, February 04, 2012:

Yes, I have the directory (with subdirectoris and files) at /var/www/openemr.

If I go to localhost/openemr in my browser I get the login interface. I can log in but I cannot see my patient data.

Thanks.

bradymiller wrote on Saturday, February 04, 2012:

Hi,

Two things then:

1) type ‘sudo mysql’
2) type ‘show databases;’ (paste what is shown here)
3) type ‘exit’

Then look at the file library/sqlconf.php in your previous 3.1.0 backup and what is the $dbase variable set to.

-brady

rdh61 wrote on Saturday, February 04, 2012:

First of all, sorry. I said “I can log in but I cannot see my patient data.” This is not true (I remembered this from a previous point in the whole process). But now, when I try to login to my openemr, I get the following text in the browser:

**ERROR: insert failed: insert into log ( date, event, user, groupname, success, comments, crt_user) values ( NOW(), ‘login’,‘admin’,‘Default’,‘1’,‘success: ::1’,’’)

Error: Unknown column ‘success’ in ‘field list’**

Second, your queries:

robert@robert-laptop:~$ sudo mysql
password for robert:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)

**robert@robert-laptop:~$ show databases
The program ‘show’ is currently not installed.  You can install it by typing:
sudo apt-get install nmh
robert@robert-laptop:~$ **

(N.B. I have run sudo apt-get install nmh as instructed, it installed successfully, I have rebooted, but I still get the above!)

library/sqlconf.php:

<?php
//  OpenEMR
//  MySQL Config
//  Referenced from sql.inc

$host = ‘localhost’;
$port = ‘3306’;
$login = ‘openemr’;
$pass = ‘G64WiuKPLE5h’;
$dbase = ‘openemr’;

//Added ability to disable
//utf8 encoding - bm 05-2009
$disable_utf8_flag = false;

$sqlconf = array();
$sqlconf= $host;
$sqlconf = $port;
$sqlconf = $login;
$sqlconf = $pass;
$sqlconf = $dbase;
//////////////////////////
//////////////////////////
//////////////////////////
//////DO NOT TOUCH THIS///
$config = 1; /////////////
//////////////////////////
//////////////////////////
//////////////////////////
?>

yehster wrote on Saturday, February 04, 2012:

This likely means that you need to upgrade your database.

point a browser to
http://webserver/openemr/sql_upgrade.php
or
http://ubuntu/openemr/admin.php

for more details refer to
http://www.open-emr.org/wiki/index.php/OpenEMR_Upgrade_Guides

rdh61 wrote on Monday, February 06, 2012:

Hi,

These pages you directed me to give 404 Not Found:

http://webserver/openemr/sql_upgrade.php
http://ubuntu/openemr/admin.php

I already followed the instructions for Ubuntu on:

http://www.open-emr.org/wiki/index.php/OpenEMR_Upgrade_Guides

Failing all else, can anybody please tell me how to purge my system completely of openemr, including the database, so that I can reinstall version 3.2 from scratch. At least that was working and I have a backup which I can restore.

Many thanks.

yehster wrote on Monday, February 06, 2012:

Sorry for not being clear enough
You are meant to replace ubuntu/webserver in the URLs I posted with 127.0.0.1
These are upgrade/administrative pages of OpenEMR.  they will give you more information about your own system.

rdh61 wrote on Monday, February 06, 2012:

That’s brilliant! Problem solved by upgrading my database with http://127.0.0.1/openemr/sql_upgrade.php. I can now log in and see my client data. Many thanks yehster and Brady, you’ve both been great.

bradymiller wrote on Monday, February 06, 2012:

Hi,

Also need to do:
1) acl_uprade via http://127.0.0.1/openemr/acl_upgrade.php

and copy over directories from your old 3.2 install to your new install:
/openemr/documents (COPY TO) => openemr/sites/default/documents
/openemr/edi (COPY TO) => openemr/sites/default/edi
/openemr/era (COPY TO) => openemr/sites/default/era
/openemr/custom/letter_templates (COPY TO) => openemr/sites/default/letter_templates

-brady

rdh61 wrote on Monday, February 06, 2012:

Thanks. Will do.

lamspc wrote on Monday, September 09, 2013:

Hello Brady,
I currently have a debian (squeeze) linux box running openemr 4.1.1. I want to migrate to another box with Debian 7 (wheezy) where I would like to install openeemr 4.1.2.
could you please summarize for me steps to make this transition - I have made a few attempts to install and transfer to the new box, but it is all a right old mess. My original box with 4.1.1 is safe and sound and is the production server.

Please help

bradymiller wrote on Monday, September 09, 2013:

Hi,

  1. Copy over the /var/www/openemr directory to new box.
  2. Mysqldump your openemr database and then place it in your new box (on new box before you bring in the old database, though, create the openemr mysql database “shell” and the openemr mysql user and ensure the mysql user has privileges to use the mysql database).
  3. Ensure you can login to OpenEMR 4.1.1 on the new box and it is working fine.
  4. Then use the ubuntu/debian 4.1.2 package on your new box which will upgrade your 4.1.1 to 4.1.2: http://www.open-emr.org/wiki/index.php/Ubuntu_Package_Upgrade_to_4.1.2

-brady
OpenEMR

lamspc wrote on Tuesday, September 10, 2013:

Hello Brady,
thanks for the suggestions - couple of clarifications:
2. mysqldump - when you say ‘place it in the new box’ - do you mean simply extracting the file and copying it to /var/lib/mysql? Or do you mean using the mysql create database command to create ‘openemr’ database, create openemr mysql user and then importing the dump into this new db?

I now have an additional problem - after I messed up the 4.1.2 install in the new box, I tried to purge remove it - but only after I deleted the /sites/default directory. I am now unable to remove package or even re-install it. Any suggestions?
Many thanks

Paul

bradymiller wrote on Tuesday, September 10, 2013:

Hi,

Use the mysql ‘mysqldump’ command to create a .sql file of your database:
http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/
(don’t copy things from var/lib/mysql since may not be compatible if change mysql versions)

Then do:
“using the mysql create database command to create ‘openemr’ database, create openemr mysql user and then importing the dump (.sql file) into this new db”

to clean the package from your new 4.1.2 box, yank:
/var/www/openemr
/etc/openemr
/var/log/openemr

and then yank the openemr mysql database

and then do the following to manually remove a ubuntu/debian package:

(I have not tried this method before; in ubuntu I generally just yank the openemr entry from file described here: http://itechlog.com/linux/2008/12/18/fix-broken-package-ubuntu/ )

then should be ok to use the 4.1.2 package to install/upgrade.

-brady
OpenEMR

lamspc wrote on Thursday, September 12, 2013:

Thanks a lot!
Paul