Access denied for user 'openemr'@'localhost'

hadrins wrote on Sunday, May 18, 2008:

Sorry if this is a repeat question int he forum. Is there a way to search them?

After installing, I am getting the following eror in my browser.

Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user ‘openemr’@‘localhost’ (using password: YES) in /var/www/htdocs/openemr/library/adodb/drivers/adodb-mysql.inc.php on line 335
Check that mysqld is running.

ERROR: Could not connect to server!

Error: Access denied for user ‘openemr’@‘localhost’ (using password: YES)

In my Apache log I have.

[Sun May 18 11:32:35 2008] [error] PHP Warning:  mysql_pconnect() [<a href=‘function.mysql-pconnect’>function.mysql-pconnect</a>]: Access denied for user ‘openemr’@‘localhost’ (using password: YES) in /var/www/htdocs/openemr/library/adodb/drivers/adodb-mysql.inc.php on line 335

I can use MySQL Administration Tool and login to the database using openemr and the password I setup for it. I mysqld is running. I did notice that if I use the command line and connect to the database using mysql -u openemr -p and use a blank password I get in, if I put inthe correct password I do not.

I did have some trouble during the first install and hadto remove the database and start again. Wondering if that was part of the problem.  Would really like to get this to work.

Thanks

drbowen wrote on Sunday, May 18, 2008:

***
I can use MySQL Administration Tool and login to the database using openemr
and the password I setup for it. I mysqld is running. I did notice that if I
use the command line and connect to the database using mysql -u openemr -p and
use a blank password I get in, if I put inthe correct password I do not.
***

This means that the "openemr" user password is blank in the MySQL database.

Getting the permissions on a MySQL database just right can be tricky.  As an example the following on a MySQL database are considered to be separate accounts:

openemr@"localhost"
openemr@127.0.0.1
openemr@"morgan"

even if localhost = 127.0.0.1 = morgan

to you and to me.  The computer will not see it this way.

The simplest thing is at the command line is to change the "openemr" user to the correct password:

mysql> \u mysql

mysql> Update user set password=md5(‘yourpasswordhere’) where user=‘openemr’;

After messing around with MySQL permissions for hours on end trying to figure stuff out I always set up a new database by dropping the bad database.  Things are much different if you have line data, but from your comments I am assuming that you do not yet have live data (right?).

If you have live data do not do this.  Make sure any live data is backed up. Otherwise:

mysql>  Drop database openemr;

but you also have to delete the old insertion of the "openemr" user in the "mysql" database:

mysql>  \u mysql
mysql> delete username from user where user="openemr";
mysql> delete username from db where user="openemr";

Make sure all references to the malformed user are removed.

check with:

mysql> select * from user;
mysql> select * from db;

After all references are removed, restart the setup.php :

When filling in the blanks put in the openemr usrs and password that you want set up.

user:  openemr
password:  yourpasswordhere

add the mysql root user and root user password.

finish setup.

You should then be able to login with the name of the user "admin"  or whatever you changed it to in the setup form and the password "pass".

Sam Bowen, MD

hadrins wrote on Thursday, May 22, 2008:

Thanks,

But that didn’t work.  I have even tried deleting everything and starting over.  Everything creates and installs but when I load openemr to login for the first time I get the same error.  I am going to look at the requirements closer and build a system to just to do this and then look around. The system I was trying to install on already has several MySQL databases running.  Perhaps it is the version I am using 4.1

drbowen wrote on Thursday, May 22, 2008:

Have you installed mysqli ?

Sam Bowen, MD

drbowen wrote on Thursday, May 22, 2008:

The error messages mean that you are not connecting to the MySQL database.  This generally means the password is incorrect (or something is wrong with permissions).

Sam Bowen, MD

hadrins wrote on Friday, May 23, 2008:

Got it!!!

After messing around a little, I went to /var/www/htdocs/openemr/library/sqlconf.php and change the setting from localhost to the IP address of the server.  And it worked.  Now I can put off upgrading MySQL server.  At least until this last HIPPA dead line has past.

I am able to login remotely.  The way I like it cause I almost never use the console of the server.

Thanks,