Access the MYSQL database Open edX from local machine

Hi,

I am deploying Open edX on an EC2 instance in AWS using Tutor. I want to access the MySQL database from my local machine. I am attempting to port forward the MySQL container to the EC2 instance’s port and then access the database host port.

Here is what I have tried to edit file: /.local/share/tutor/env/local/docker-compose.yml. I added ports 3306

  mysql:
    image: docker.io/mysql:5.7.35
    command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
    restart: unless-stopped
    user: "999:999"
    privileged: false
    ports:
      - 3306:3306
    volumes:
      - ../../data/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: "xxx"

After making the changes, I restarted the MySQL service using the command tutor local restart mysql. However, the port mapping did not work as expected.

I kindly request your assistance in resolving this issue.

Thank you.

I tried this change, and it works for me. I suspect the issue is a firewall between your machine and the EC2 instance, not an issue with the docker ports.

Try using SSH to open a shell on the EC2 instance, then run mysql --host=127.0.0.1 --port=3306 --user=root --password. When prompted, enter the root password from the docker-compose.yml file, and you should get the MySQL shell. If that works, then the issue is with your EC2 firewall or at the network level, not at the Tutor/docker level.

Thank you @braden.
The command tutor local restart mysql doesn’t actually restart the MySQL container. I had to relaunch Open edX using tutor local launch , and now it works.