0

Project objective: I have a small web application in PHP / JS which allows to perform tests on different web-services on my company's website. I have a MySQL database and I containerized my project with Docker Compose version 3.3

I have a first image which contains my project code (zewcro / rheax_x) and a second image (mysql) which contains the database image

Here is the code for my docker-compose.yml

version: "3.3"
services:
  rheax:
    image: zewcro/rheax_x
    depends_on:
      - mysql 
    link:
      - mysql
    ports: 
      - "8080:80"
    networks:
      - monreseau
  mysql: 
    image: mysql
    restart: always
    volumes:
      - ./db:/docker-entrypoint-initdb.d
    environment:
      MYSQL_DATABASE: "rheaxdb"
      MYSQL_USER: "theor"
      MYSQL_PASSWORD: "secret"
      MYSQL_ROOT_PASSWORD: "secret"
    ports:
      - "3360:3306"
    networks:
      - monreseau
networks:
  monreseau:

When I deploy my image on a local server (Xampp or Uwamp) I have no problem everything works perfectly, but as soon as I deploy my compose on my production server I have errors as soon as my application tries to connect to the database:

rheax_1  | [Fri Nov 26 14:35:33.636973 2021] [php7:warn] [pid 18] [client xx.xx.xx.xx:xx] PHP Warning:  mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /var/www/html/rheax/verification.php on line 8, referer: http://xxx.xxx.xxx.xxx:8080/rheax/
rheax_1  | [Fri Nov 26 14:35:33.637080 2021] [php7:warn] [pid 18] [client xx.xxx.xxx.xxx:1xxx5] PHP Warning:  mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in /var/www/html/rheax/verification.php on line 8, referer: http://xxx.xxx.xx.xx:8080/rheax/
rheax_1  | xxx.xxx.xx.xxx - - [26/Nov/2021:14:35:31 +0000] "POST /rheax/verification.php HTTP/1.1" 200 342 "http://xxx.xxx.xx.xxx:8080/rheax/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36" ````

Line 8 of verification.php is as follows:

      $port        = 3360;
      $db = mysqli_connect($db_host, $db_username, $db_password, $db_name, $port) or die('could not connect to database');

I've tried a lot of things but I'm starting to not really know where to look. If anyone has an idea, I'm interested.

Thank you.

  • Have you searched for that error? What have you tried? Have you seen this? https://stackoverflow.com/questions/50026939/php-mysqli-connect-authentication-method-unknown-to-the-client-caching-sha2-pa – Diogo Simões Nov 26 '21 at 15:29
  • Does this answer your question? [php mysqli\_connect: authentication method unknown to the client \[caching\_sha2\_password\]](https://stackoverflow.com/questions/50026939/php-mysqli-connect-authentication-method-unknown-to-the-client-caching-sha2-pa) – Tangentially Perpendicular Nov 26 '21 at 18:18

0 Answers0