Problèmes de Connexion MySQL lors de l'Utilisation de Tutor pour Open edX

Description du Problème :

J’ai rencontré plusieurs difficultés en utilisant Tutor pour déployer Open edX sur Kubernetes. Les problèmes spécifiques sont les suivants :

  • Impossible de connecter MySQL avec les conteneurs CMS et LMS.
  • Erreurs de connexion MySQL pour les utilisateurs openedx et root.

Étapes pour Reproduire :

  1. Initialisation de Tutor avec tutor local quickstart (réussi sans erreurs).
  2. Déploiement de Open edX sur Kubernetes avec tutor k8s start.
  3. Lors de l’exécution de tutor k8s init, j’ai reçu l’erreur suivante :
    Error: Job mysql-job-20240806152831 failed. View the job logs to debug this issue.
  4. Tentative de connexion à MySQL depuis les conteneurs CMS et LMS et aussi SQL :
    kubectl exec -it -n openedx pod/mysql-5db88664b4-blztv – bash
    mysql -u openedx --port 33060 -p
    la reponce est :
    ERROR 1045 (28000): Access denied for user ‘openedx’@‘localhost’ (using password: YES)
    RQ : Le mot de passe utilisé était celui spécifié dans les variables d’environnement via tutor config printroot /env.
  5. La tentative de connexion donne toujours l’erreur suivante :

ERROR 1045 (28000): Access denied for user ‘openedx’@‘localhost’ (using password: YES)
6. Tentative de connexion en tant que root :
mysql -u root -p
Le mot de passe spécifié ne fonctionne pas non plus.

**Logs du Job MySQL :
2024-08-06 13:50:42+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
2024-08-06 13:50:42+00:00 [Note] [Entrypoint]: Switching to dedicated user ‘mysql’
2024-08-06 13:50:42+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
2024-08-06 13:50:42+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
You need to specify one of the following as an environment variable:
- MYSQL_ROOT_PASSWORD
- MYSQL_ALLOW_EMPTY_PASSWORD
- MYSQL_RANDOM_ROOT_PASSWORD

Hi,

In my experience because of the error I see

“2024-08-06 13:50:42+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified”

You must wait for the mysql container to finish, since if this process is truncated or does not finish on time the following installation steps fail.

Check the log of the mysql container to see if it finished initializing or was truncated and then try to install again.

Thanks for your response,
The pod of mysql is already functionnal , but the mysql-job has failed and when i checked the logs I have seen that it was unable to connect to mysql , that s why i have done kubectl exec … in order to check if all is well or not , and i have faced the issue of connecting to the database even from inside the pod of mysql

If your installation is new, delete the directory or volume where the mysql data is stored and try again.

I @Med_amine_Boujelbene!
Even though it’s possible, I’d not recommend using MySQL inside your K8s cluster (and actually, none of the workloads that use persistent volumes, namely MongoDB, Redis, OpenSearch). You can do for testing, but in production environments you will sooner or later have big problems. Instead, create your databases separately or -better- use a DB-as-a-service from your cloud provider and connect them to your cluster.

Hope it helps!
Andrés.

Hello,

Thank you for your assistance. I have indeed deleted the directory and volume where the MySQL data was stored and reinstalled the database. The connection issue has been resolved, and I can now access the database.

However, it seems that the data migration was not performed correctly. The database appears to be empty, with no tables present. Additionally, when checking the logs for the backend service lms, I encounter the following error:

django.db.utils.ProgrammingError: (1146, “Table ‘openedx.waffle_switch’ doesn’t exist”)

It appears there is an issue with the database migrations. Could you please advise on how to resolve this issue and ensure that all migrations are properly applied?

Thank you in advance for your help.

Hi @Med_amine_Boujelbene, sorry for the late reply. In case you didn’t find the solution yet, tutor k8s launch or tutor k8s do init will run all migrations.