Cannot connect to mysql on OpenEMR Cloud Express

Situation
I have installed OpenEMR Express edition (5.0.1) on AWS. I am not able to get to database from the website as phpmyadmin is disabled. I am trying to connect to mysql locally from the ubuntu server using mysql -h 127.0.0.1 -u root -p (root) . I am getting error (ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111))

Please HELP!

OpenEMR Version
I’m using OpenEMR version => Express edition (5.0.1) on AWS

Thanks!

hi @NDave, there’s some nice info here, openemr-devops/packages/lightsail at master · openemr/openemr-devops · GitHub

Hi @stephenwaite

Yes, i followed the steps mentioned on the link you provided before & it did not work

I was able to figure out the way!!

The key is to not use localhost or 127.0.0.1 as IP but to find out the IP bound to the mysql docker container & use that.
Below are the steps to figure out the IP for mysql docker container

docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
88f8a6baf98c openemr/openemr:5.0.1 “./run_openemr.sh” 2 months ago Up 4 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp lightsail_openemr_1
d05167f16b1f openemr/mysql-xtrabackup:latest “docker-entrypoint…” 2 months ago Up 4 hours 3306/tcp lightsail_mysql_1

So now we know the container id for mysql starts with d05167f16b1f*

Next we go to /var/lib/docker/containers/ and we will find dir which starts with d05167f16b1f*

We check hosts file in that directory & it will be something like below

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.81.0.3 d05167f16b1f

We need to use 172.81.0.3 as IP to connect to mysql & it works!

2 Likes

I’m surprised that worked. I may need to experiment with that process. Thanks!

@jesdynf, Hello!
Why are you surprised that i was able to connect using the bind IP instead of 127.0.01?

It just surprised me that you could break into Docker’s private networks like that – I thought it took better care of ingress.

Hi Nehal,

I followed all the steps you mentioned but i see the following

ubuntu@ip-172-31-8-184:~$ sudo nano /etc/hosts
GNU nano 4.8 /etc/hosts
127.0.0.1 localhost

The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

I dont see the IP for mySQL , so how do i connect ??

any help will be very helpful …

Hi Stephen,

I also followed the link that you shared but I am not able to access the folder structure that is mentioned it gives me below error

ubuntu@ip-172-31-8-184:~$ cd /root/openemr-devops/packages/lightsail
-bash: cd: /root/openemr-devops/packages/lightsail: Permission denied
ubuntu@ip-172-31-8-184:~$

You’ll need to operate as root to read directories owned by the root user, or interact with the running Docker service.

1 Like

Thanks Asher, I was able to connect to the database within the container and access all the tables.

Thank you !!

May I ask you if you are aware on how to authorize the Swagger, I followed Stephen video and loyally did all the same steps the demo link opens up but not my configured OpenEMR cloud express

Any guidance will be of much help.

Regards,
Ayesha