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.

Hello. I have the same issue.

After running docker ps | grep mysql and tutor local logs --tail=100 mysql , I have these:

mysql-1  | 2024-05-30 20:33:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.1.0-1.el8 started.
mysql-1  | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
mysql-1  | 2024-05-30T20:33:11.757960Z 0 [System] [MY-015015] [Server] MySQL Server - start.
mysql-1  | 2024-05-30T20:33:12.053581Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
mysql-1  | 2024-05-30T20:33:12.055794Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.1.0) starting as process 1
mysql-1  | 2024-05-30T20:33:12.057645Z 0 [Warning] [MY-013243] [Server] --character-set-server: The character set UTF8MB3 is deprecated and will be removed in a future release. Please consider using UTF8MB4 instead.
mysql-1  | 2024-05-30T20:33:12.057654Z 0 [Warning] [MY-013244] [Server] --collation-server: 'utf8mb3_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
mysql-1  | 2024-05-30T20:33:12.063397Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysql-1  | 2024-05-30T20:33:12.897324Z 1 [ERROR] [MY-012526] [InnoDB] Upgrade is not supported after a crash or shutdown with innodb_fast_shutdown = 2. This redo log was created with MySQL 5.7.35, and it appears logically non empty. Please follow the instructions at http://dev.mysql.com/doc/refman/8.1/en/upgrading.html
mysql-1  | 2024-05-30T20:33:12.897541Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
mysql-1  | 2024-05-30T20:33:13.328843Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
mysql-1  | 2024-05-30T20:33:13.329206Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
mysql-1  | 2024-05-30T20:33:13.329291Z 0 [ERROR] [MY-010119] [Server] Aborting
mysql-1  | 2024-05-30T20:33:13.329810Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.1.0)  MySQL Community Server - GPL.
mysql-1  | 2024-05-30T20:33:13.330769Z 0 [System] [MY-015016] [Server] MySQL Server - end.

Please help.