5.01 installation/setup fail to access MariaDB on Debian 9 and failed to Install

First, I’ve read every post I could find related to this problem before posting.
Second, I am a seasoned SYS ADMIN, DBA, and programmer. Granted PHP is not my favourite language, but that’s a different story.

I am running MariaDB, PHP 7.2, Apache 2.4x, et al on Debian 9.x. Everything up to date as of this morning.
I have no problem connnecting PHP to MariaDB via mysqli() as root with password; wrote a couple new test scripts just to be sure, and confirmed no problem.
Lots of existing PHP is hammering away at the db from other vhosts on Apache.
However, the OpenEMR 5.01 setup is not happy.

So, I’m trying to install OpenEMR from the web interface, as https://fqdn/emr/setup.php and after everything looks good and I fill out the page with access accounts including the db root user and password, it tanks out and reports:

mysqli_connect(): (HY000/1698): Access denied for user ‘root’@‘localhost’ in /foo/bar/htdocs/emr/library/classes/Installer.class.php on line 613, referer: https://foo.bar/emr/setup.php?site=default

So, I stop using TLS in case that is the problem. Nope. I move back to the DocumentRoot directory to see if that is the problem. Nope. I change PHP versions. Still nothing. grrrrr I start doing things that make no sense, because frankly the problem makes no sense.

Apache is working, MariaDB is working, PHP and mysqli() are working. grrrrr

Then I look at the priviledges table in MariaDB and discover:
Host | User | Password | plugin |
±----------±--------------------±--------------±---------------+
| localhost | root | *[snip] | unix_socket |

What is up with that new plugin. I’ve never used it before, and I didn’t install it. I read on a couple of boards that it lets the root user log in to the RDMBS without a password if they are local to the box. That can’t be correct, so RTFM:

This plugin allows the user to use operating system credentials when connecting to MariaDB via Unix socket.

Unwritten here, it also prevents login for root when not on the console. Still, my other PHP is working fine from being served from Apache. Still, this is an important piece of information. I must investigate the workings of this plugin.

OK, so I try it and low and behold, I can log in from the shell prompt with or without a password. This is weird, because the system password for root is not the same as the RDBMS (MariaDB) password for root. Still, I am now increasingly suspicious of the root user on MariaDB as being the problem, thanks to this authentication plugin. It isn’t affecting my other PHP apps, but it still “something is rotten in the state of Denmark”.

I create a new user in MariaDB, and give them all of the priviledges that root has. I restart MariaDB, and try again.

Voila. The installer moves forward past the previous error(s).

Conclusion: If you are on Debian 9 using MariaDB and have root access problems with the installer, either disable the unix_socket plugin, or create an additional user with root priviledges and use this new user as the “root” user for installation; I did the latter, so inside MariaDB:

Mariadb> CREATE USER ‘installer’@‘localhost’ IDENTIFIED BY ‘somepassword’;
Mariadb> GRANT ALL PRIVILEGES ON . TO ‘installer’@‘localhost’ WITH GRANT OPTION;
Mariadb>FLUSH PRIVILEDGES;

Then restart MariaDB and all is good. Use the “installer” user instead of “root” to get the job done from the web install.

I now return you to your regularly scheduled programming. :slight_smile:

1 Like

Wow, that’s a really interesting issue going on; glad you were able to figure it out! Thanks for posting, hopefully it helps the next person.

Going to tag @jesdynf @sjpadgett and @brady.miller here just so they’re aware.

“Debian 9 / MariaDB may require non-root superuser for install” – noted; thanks for the heads-up.