'Connection for controluser as defined in your configuration failed on ubuntu20.04 container
I'm trying to have one docker container with: ubuntu 20.04, on top of which I add apache, php, mysql and phpmyadmin (all on the same container)
What's installed:
- mysql Ver 8.0.29-0ubuntu0.20.04.2 for Linux on x86_64((Ubuntu))
- Apache/2.4.41 (Ubuntu)
- phpmyadmin 4:4.9.5+dfsg1-2
- PHP 7.4.3
This is the content of my dockerfile:
FROM ubuntu:20.04
MAINTAINER Myself
RUN apt-get update
RUN apt-get -y upgrade
RUN DEBIAN_FRONTEND=noninteractive apt -y install apache2 php libapache2-mod-php mysql-server php-mysql phpmyadmin
# I've set the dbuser to 'admin' dbpass to 'admin' here
COPY ./config-db.php /etc/phpmyadmin/config-db.php
RUN cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
RUN a2enconf phpmyadmin
COPY ./start.sh /start.sh
COPY ./init.sh /init.sh
RUN bash /init.sh
CMD ["bash", "start.sh"]
And this is the content of my init.sh:
#!/bin/bash
service mysql start
# I'm creating the phpmyadmin database here
mysql -u root --password= < /usr/share/phpmyadmin/sql/create_tables.sql
mysql -u root --password= -e "CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin';"
mysql -u root --password= -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost';"
mysql -u root --password= -e "FLUSH PRIVILEGES;"
mysql -u root --password= -e "CREATE DATABASE PROJECT_MANAGEMENT;"
And this is the content of my start.sh:
#!/bin/bash
service mysql start
apachectl -D FOREGROUND
I run my container through docker build -t test .
and docker run -d -p 80:80 test
(even tried to add -p 3306:3306
...). I can access apache2 through localhost:80 and I'm pretty sure mysql is up because my queries worked.
But logging in to localhost/phpmyadmin with username:admin and password:admin just won't work: " Cannot log in to the MySQL server", " mysqli_real_connect(): (HY000/2002): Permission denied", " Connection for controluser as defined in your configuration failed.", " mysqli_real_connect(): (HY000/2002): Permission denied"
(Yes, I have tried to set controluser
and controlpass
in config.inc.php to admin/admin)
I have no idea what i have to do, I'm overly frustrated, i've tried everything that was on the internet.
Thank you
QUICK-FIX: For some reason phpmyadmin doesn't add the port to the request: I had to set the following in the file /etc/phpmyadmin/config.inc.php
: $cfg['Servers'][$i]['host'] = "{$dbserver}:{$cfg['Servers'][$i]['port']}";
after the port directive was set of course.
If someone has a good explanation that'd be greatly appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|