Setup error "unable to connect to database as root"

I am new user/admin of OpenEMR, since we are looking for a patient management system for our NGO’s office in Peru.

My first test was running it on my own Win10 PC, which worked fine. Now next step, installing it on a Raspberry Pi 3, I saw others managed this, to have it running as a mini server in the Peru office (currently only 2 users and from time to time me logged in as admin, so I guess the RP3 should be able to handle this).

I installed a fresh Raspbian Lite (which is Debian based) and installed OpenEMR with all dependencies, through SSH.
Everything seemed to have worked fine, I can access IP/openemr and enter the setup page. I want to start with a new database.

On the setup page, I leave everything default and chose passwords for MySQL and initial user, root password as suggested is blank. This gives me the following: “Connecting to MySQL Server… ERROR. Check your login credentials. unable to connect to database as root”.

Do I need a specific password instead of something chosen? Entering a root password does not help neither (I used my sudo password of Raspbian).

Any ideas what I do incorrectly? I do have Linux experience, but not with MySQL and server setups…


Not sure if related, I got during installation the following error: “/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory”

hi @anton, welcome, sounds cool. When you setup mysql it should have asked you for a root password that you would use for OpenEMR setup.

Hi Stephen,

thanks! This should have been asked during the installation? I did not see anything…
I downloaded and installed the package (wget, dpkg), and afterwards installed the dependencies with apt-get install -f. Maybe something wasn’t properly installed or configured? The first setup page had no errors though. Could MySQL still have some missing settings or dependencies ?

Will start from scratch next week in case I missed something, earliest Tuesday I’ll find the time.


Still running into the same problem, I never get a prompt to setup the MySQL password. This should happen in the terminal session, not through the webinterface, correct?

My installation session in the terminal get stuck each time as followed (tried to uninstall and reinstall a few times)

At this moment, I can access IP/openemr, but get stuck on the 2nd setup page. Filling out the necessary passwords:

Results in the following error message:

Any idea what I do wrong? Tried also to install a few maybe missing dependencies as described here: , no difference.

Further, “sudo dpkg --configure -a” gives me a message that a database would already exist:

So no idea where to enter the initial database password to use it…

hi @anton try resetting the mysql root password

Thanks! I tried this, and even though it looked good first, trying out the new set password as described failed, it said the password was incorrect. Tried this a few times, definitely not a typo problem.

I once more de-installed everything, including the dependent packages. When reinstalling, I saw during the installation of the dependencies actually some error messages, which likely cause the problem.

Installing “mariadb-server-10.1” fails/timeouts, and this causes the installation of “default-mysql-server, mysql-server, openemr” to fail as well.

See the text file for the full error report, including journalctl -xe:
install_errors.txt (7.4 KB)

Do you have an idea what causes this problem? Should it install mariadb, or mysql only (as I understand it, mariadb replaces mysql, so it should be fine?).

Seems like others did successfully installed mariadb-server on Raspbian Stretch: , did not work for me though, since the installation already fails.
If I don’t get it running, I might want to try Jessie instead of Stretch…

Next try:
Installed Jessie instead of Stretch.
Installing OpenEMR 5.0 gives me now the expected mySQL root password field to complete, which I did not had before. But at the same time some dependencies are not found and the packages are therefore not installed, about 10-15 missing, completion of the openEMR installation failed therefore.

So, as someone else managed to install openEMR 4.1.1-1 (link to blog post above, no idea why he chose this version), I tried this, still under Jessie. This time the installation runs through, mySQL root is set and openEMR configured. I have to change the apache2 configuration as described in his post to get it running (before IP/openemr does not load), then it works fine.

Is there a reason I should not run this old version? Ideally I’d prefer still the newest version, if I get it running somehow…


Hi @anton ,
Did it list the dependencies that were not found?
Is Raspbian different than debian?

To back up to the mysql problems, Jessie and 4.11 aside:
I recall having the same issue somewhere in the distant pass, perhaps when playing around with setting up multi-site installations? Your issue seems similar. Frustrating indeed.

Before wiping out mysql or mariaDB here is something to try:
If you wanted to look at your DB via phpmyadmin you might see that there is now an openemr DB present, from your previous attempts, and the user credentials to access it in mysql_user table are incorrect or are mangled? Forget about deep diving into mysql this way… It’s a rabbit hole without a rabbit unless you are a mysql guru.

If you are sure your root username/password are correct try repeating this install step again with ALL NEW data - new DB name, Login Name/Password
but of course same Name for Root Account and Password there.

Also new “OPENEMR USER” information.
Initial User: Admin_anton1
Initial User Password: *********

The First/Last name should not matter.
Keep “Initial Group” as Default.

Just wrote a long message explaining what went now wrong, and suddenly it (mostly, see below) works. I installed completely fresh OpenEMR 5.0 on Stretch (also fresh setup). The dependency installation seemed stuck at the same point as earlier: stuck.txt (70.1 KB), the SSH session did not responding anymore. I did not get a prompt to setup the SQL root password, as before. The webinterface showed the same error message about the DB root password. Went to lunch. Tried again the webinterface, which gave me a different error message (openemr already installed…).
And suddenly the SSH session prompts the installation was successful. I can log in, seems everything fine the first look.

No idea what actually happened, maybe the installation just takes really long without any prompt, about an half hour? Or using now actually admin/pass as first login credentials and not something else in the setup form? This was definitely different in 4.1.1… Or was the installation now completed, but I still have a database problem? ->

Now trying to create a test client. Somehow it does not let me do this, both buttons “create new client” and “search” don’t do anything (name, DOB, sex filled out). Maybe still related to the database, that it does not access it properly? Other functions like creating new users do work, inventory functions as well. Maybe they are stored differently in the database? Any ideas about this?

Beside this, Raspberry Pi seems reasonable fast for running it. Could be faster, but definitely usable!

Raspbian is basically Debian armhf with some minor changes to support the Raspberry Pi hardware better, in my understanding…

@rmagauran Installed phpmyadmin, setting it up with a new database failed (similar failure: root password problems…), so selected the non-configured setup. Not really sure how to use phpmyadmin, especially without GUI?

hi @anton ,

Ensure you clear your browser cache.

Also, another thing to think about is docker. Can raspberry do dockers ok(if so, then no need to worry about dependencies or any of that). If so, then is really simple to get OpenEMR/Mysql/Phpmyadmin dockers going.


Clearing the cache solved this last mysterium! I can now create a new client! Thanks!

Docker: Seems so:
Haven’t used docker yet, but thanks for the tip, I will look into this!
This setup now was the proof of concept on my private equipment, thinking of installing it maybe bootable from USB rather the standard SD setup (should improve the stability, and maybe the speed. But Ethernet hangs on the USB port, so it might slow things down in the end…)

1 Like

Just read out of curiosity a bit about docker. Since the Raspberry Pi is an ARM device, an arm-docker would be needed, is this correct? I assume the current available docker is only for x86?

oh, Docker sounds more complicated on Raspberry Pi. Agree would need ARM dockers, which could potentially build from the starting dockerfiles. Another challenge :slight_smile:

Right now I trying to setup an automatic backup, but seems the SQL root password still haunts me. As described here: , I try to do save the database, but it fails:

sudo mysqldump --opt --quote-names -u openemr -p openemr | gzip > openemr.sql.gz
Enter password:
mysqldump: Got error: 1045: “Access denied for user ‘openemr’@‘localhost’ (using password: YES)” when trying to connect

I tried both empty and all password I possibly could have set, but as mentioned before, I never actually entered this password. Is this password set randomly?

Changing the password as mentioned by Stephen above fails as well, as earlier described. I found this article about mariadb passwords: and performed the first step, which allowed me to set a root password (finally! here the old password leaving blank worked!). Nevertheless, the database dump line above still does not work and tells me I would have an incorrect password, even though I use the one just set by “sudo mysql_secure_installation”.

Any help about this password? Or would my backup to be different for mariadb?
Or is it possible to do the backup (and later restore) without the password? Which folders would I need to copy, /var/www/openemr/ and the database? which folder/files contain the database?