-1

I'm trying to connect to mysql database running in docker which is invoked by tutor:

tutor dev launch

which generates the config.yml file below

CMS_HOST: studio.local.overhang.io
CMS_OAUTH2_SECRET: ue5LfJvi7LyJ5d0kN1mKwXWH
CONTACT_EMAIL: contact@local.overhang.io
ENABLE_HTTPS: false
ID: e7t5Qli0r4Ue4qePDDKP3yHb
JWT_RSA_PRIVATE_KEY: '-----BEGIN RSA PRIVATE KEY-----

  MIIEogIBAAKCAQEA5CGyUuSGEoUkgeRQpjpQyZmhPY7YtVIdsNzGaYGjC3XJC3ZT

  3BhQTR0M4xrEXONDueODk5ReRwDRMtWmuJo57gDnK0yQ+3mNiCB5Vzuz7q90tMWb

  oTsX9wcvOCOqlWXvW/BKaNpB872pRo7yPA2BBmsAZuA0lOf42oyhEep/LgHk9XQr

  LHD5l6y6uWIsxMorCmw19pn987RgyHcs0ewFOY6M/ftnnMFus0b+tc3t3x6llfRe

  /WTvEEC1MFjSGnawXDWU6b14RJYgBX6owHUZr3yUY8ROcklIGYferWbG3K8JwRui

  RyboorrwGfGUcFpKgkLwFJq4k+ut6Fgxmf1I9QIDAQABAoIBAE7ZxsUX769fDatH

  uwh5h4rm6vBX+1dQtqp25K16/Vvsrjyj/YBJdxfwPpAQpGZmtvX9SXEtCxkHk0c6

  yZFs3TECZuR0ZnhFH0I51zbrj9mkE3aYBp7HyhS8CvogecmBniXs/AsZxUn1+BhH

  ODrBgCMzwMPOIt6E/2Kq0NFcd/DyV3TI1SPZZAoZRJMf12nxsCOrJ10z+4z27wvw

  cVHkxfeizo1bLdaSDzOSDswh2QZf02dO9ByeaGyOeKr2QMaxGqIwunwxE6WNYRG2

  hVNIFyWs/bSmnjTQ3K1mKh5r0XRPmOzVQUoqFnUpeA1N9APMby2aRa/qzflcnP1z

  PIpQRVECgYEA50yrFQn0HdECID8u3pBQWhOth2Q/cZM9LsK5ebTEq7/k1Qz26xFR

  89HBUOb9+vakjYS9mU6xEGTtDdo2k/i9hdK2kZS2UA+P5x05uo6L1frVJpt/0ROi

  3u0BLb2K23tWM2hlGG/NWLwbp4Jn6VIq6hSxRa9qRHx11AYULy65RTsCgYEA/H5s

  qgpGKSyLm3eqCEBlz9GA2fcUVdkXcxYQ6L8luUL0jfGKWYkhkg2VYj6NtZtNGB9K

  n8J5aDJeZhahxWBnAyu/Jv0yvLkxucyQEr77dHZzCtqG6OuoP1VFAz/8plmDuTqr

  +0TYW2zt4fGQnX2+sLxNDSUgkJ1UmSvQFFkhB48CgYA6aATHgkTvhoi35dyK/Pwd

  Uty91JWks15+wVMepYQILqO1HNn5D92W6P+c00eNKNzyk3NhFBroHeQyXEjt4qDQ

  +x1484l5/AQFgz7Bmh87gGR0pE2JWSEGk+h5SWSX+bQRtSnaGtlKr+13xhlBNKt7

  gpAlHZ+C/b6vNH3CUFUeYwKBgDCDWf2R28ktdeV5KIJNXUKAznESuCWGgKrsInOV

  xnnCE5ryPdLWNk0JrxohSrkKDdYErSHlC86pXtnen1Z9H03Mqf2jyIvaSWOZmlT/

  vPCzkYcUVbeLD9ibWZc2RCTyLgz46PJuV+O5Gju/XjnkXy81/tf3ujoPAKIteN1w

  ApihAoGAcz+xo1VYxZXZzxID0hS2ikLWBcnThcjYN6dsKB7mh1P+EBrDFpT3Ozjp

  EyzfjcCgQAcWuWooYF85MPq4YE/Dgu1GmzHfKqLXALw2Z7TR5Hl9oZxzRQb2AMKt

  eBty8RjunNs2dt9n4l2VrWeIFiNKlR8el/RzXk4ZhcW84KTq7mM=

  -----END RSA PRIVATE KEY-----'
LANGUAGE_CODE: en
LMS_HOST: local.overhang.io
MYSQL_ROOT_PASSWORD: 9vXd2uA6
OPENEDX_MYSQL_PASSWORD: esJCvsog
OPENEDX_SECRET_KEY: R6m93ga6apJcYJDjCMSUrPNF
PLATFORM_NAME: My Open edX
PLUGINS:
- mfe

so I'm assuming the user is root and the password is either 9vXd2uA6, esJCvsog, not sure which one, so I wait until the mysql container is up:

================================================
        Database creation and migrations
================================================
Initialising all services...
Running init task in mysql
docker-compose -f tutor/tutor-dev/env/local/docker-compose.yml -f tutor/tutor-dev/env/dev/docker-compose.yml -f tutor/tutor-dev/env/dev/docker-compose.tmp.yml --project-name tutor_dev -f tutor/tutor-dev/env/local/docker-compose.jobs.yml -f tutor/tutor-dev/env/dev/docker-compose.jobs.yml -f tutor/tutor-dev/env/dev/docker-compose.jobs.tmp.yml run --rm mysql-job sh -e -c 'echo "Initialising MySQL..."
mysql_connection_max_attempts=10
mysql_connection_attempt=0
until mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e '"'"'exit'"'"'
do
    mysql_connection_attempt=$(expr $mysql_connection_attempt + 1)
    echo "    [$mysql_connection_attempt/$mysql_connection_max_attempts] Waiting for MySQL service (this may take a while)..."
    if [ $mysql_connection_attempt -eq $mysql_connection_max_attempts ]
    then
      echo "MySQL initialisation error" 1>&2
      exit 1
    fi
    sleep 10
done
echo "MySQL is up and running"

# edx-platform database
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "CREATE DATABASE IF NOT EXISTS openedx;"
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "CREATE USER IF NOT EXISTS '"'"'openedx'"'"';"
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "ALTER USER '"'"'openedx'"'"'@'"'"'%'"'"' IDENTIFIED BY '"'"'esJCvsog'"'"';"
mysql -u root --password="9vXd2uA6" --host "mysql" --port 3306 -e "GRANT ALL ON openedx.* TO '"'"'openedx'"'"'@'"'"'%'"'"';"'
[+] Running 1/0
 ⠿ Container tutor_dev-mysql-1  Running                                    0.0s
Initialising MySQL...
mysql: [Warning] Using a password on the command line interface can be insecure.
MySQL is up and running

and I try:

% mysql -u root --password="9vXd2uA6" --port 3306 -h mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host 'mysql' (8)

and

% mysql -u root --password="9vXd2uA6" --port 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

and

% docker ps
CONTAINER ID   IMAGE                                            COMMAND                  CREATED         STATUS         PORTS                    NAMES
8e4c6ab90f55   openedx-dev:15.2.0                               "celery --app=cms.ce…"   5 minutes ago   Up 4 minutes   8000/tcp                 tutor_dev-cms-worker-1
75ed5ee2ef21   openedx-dev:15.2.0                               "./manage.py cms run…"   5 minutes ago   Up 4 minutes   0.0.0.0:8001->8000/tcp   tutor_dev-cms-1
4f94ee5fd720   overhangio/openedx-gradebook-dev:15.0.4          "docker-entrypoint.s…"   5 minutes ago   Up 4 minutes   0.0.0.0:1994->1994/tcp   tutor_dev-gradebook-1
e28c194381b0   overhangio/openedx-account-dev:15.0.4            "docker-entrypoint.s…"   5 minutes ago   Up 4 minutes   0.0.0.0:1997->1997/tcp   tutor_dev-account-1
1707bf5263f7   openedx-dev:15.2.0                               "celery --app=lms.ce…"   5 minutes ago   Up 4 minutes   8000/tcp                 tutor_dev-lms-worker-1
3a76937f82a1   overhangio/openedx-authn-dev:15.0.4              "docker-entrypoint.s…"   5 minutes ago   Up 4 minutes   0.0.0.0:1999->1999/tcp   tutor_dev-authn-1
821e6fa12f1f   overhangio/openedx-profile-dev:15.0.4            "docker-entrypoint.s…"   5 minutes ago   Up 4 minutes   0.0.0.0:1995->1995/tcp   tutor_dev-profile-1
30685779c278   overhangio/openedx-course-authoring-dev:15.0.4   "docker-entrypoint.s…"   5 minutes ago   Up 4 minutes   0.0.0.0:2001->2001/tcp   tutor_dev-course-authoring-1
7657705346b6   overhangio/openedx-learning-dev:15.0.4           "docker-entrypoint.s…"   5 minutes ago   Up 4 minutes   0.0.0.0:2000->2000/tcp   tutor_dev-learning-1
f3289604200e   overhangio/openedx-discussions-dev:15.0.4        "docker-entrypoint.s…"   5 minutes ago   Up 4 minutes   0.0.0.0:2002->2002/tcp   tutor_dev-discussions-1
0111b9ee8228   openedx-dev:15.2.0                               "./manage.py lms run…"   5 minutes ago   Up 4 minutes   0.0.0.0:8000->8000/tcp   tutor_dev-lms-1
1aa5c71a9e38   mongo:4.2.17                                     "docker-entrypoint.s…"   5 minutes ago   Up 5 minutes   27017/tcp                tutor_dev-mongodb-1
d1a62a1e4f39   redis:6.2.6                                      "docker-entrypoint.s…"   5 minutes ago   Up 5 minutes   6379/tcp                 tutor_dev-redis-1
89ba0c7d746b   elasticsearch:7.10.1                             "/tini -- /usr/local…"   5 minutes ago   Up 5 minutes   9200/tcp, 9300/tcp       tutor_dev-elasticsearch-1
7274bb8cc66b   mysql:5.7.35                                     "docker-entrypoint.s…"   5 minutes ago   Up 5 minutes   3306/tcp, 33060/tcp      tutor_dev-mysql-1

then all the below fails as well:

% docker run -it mysql:5.7.35 bash
root@b862b4a24e28:/# mysql -u root --password="9vXd2uA6" --port 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@b862b4a24e28:/# mysql -u root --password="9vXd2uA6" --port 3306^C
root@b862b4a24e28:/# mysql -u root --password="9vXd2uA6" --port 3306 -h mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2005 (HY000): Unknown MySQL server host 'mysql' (22)
root@b862b4a24e28:/# mysql -u root --password="esJCvsog" --port 3306         
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Note: If there is a way to run the whole thing entirely outside docker, pointing to the documentation where this is addressed if one exists / specifying how to do so, will be greatly appreciated.

Zoe
  • 27,060
  • 21
  • 118
  • 148
watch-this
  • 1
  • 4
  • 20

1 Answers1

0

In a situation like this, I would suggest starting from the beginning.

Using these commands you can init MySQL again.

tutor dev stop
sudo rm -rf "$(tutor config printroot)/data/mysql"
tutor dev launch
E_net4
  • 27,810
  • 13
  • 101
  • 139
Isanka Wijerathne
  • 3,746
  • 3
  • 26
  • 34
  • I did multiple times and I still get the same issue – watch-this Jan 24 '23 at 23:44
  • I can see you have tried this command (mysql -u root --password="9vXd2uA6" --port 3306) from your LMS(b862b4a24e28). in that case you should specify the hostname. Or you can try it in MySQL container – Isanka Wijerathne Jan 25 '23 at 00:41
  • I get `ERROR 2005 (HY000): Unknown MySQL server host 'mysql' (22)` in both the container and the outside the container. Is there a way to run `tutor` without docker, using `manage.py runserver` that you know of? Because docker is extremely inconvenient and I already wasted enough hours on this shit – watch-this Jan 25 '23 at 01:01
  • Many Open edX developers have chosen the tutor as their first option. I do not agree with "this shit " Did you specify the hostname? I do not see you have. – Isanka Wijerathne Jan 25 '23 at 01:17
  • 1
    Choosing docker as a development environment is a poor choice and a huge waste of time. Instead of just running `manage.py runserver`, it adds a lot of overhead, additional issues and firefighting you have to deal with on top of any existing issues you're trying to fix, not to mention the additional time wasted awaiting image rebuilding each time you make changes. Not sure about how agreeing/disagreeing with an expression I'm using is contributing to the resolution of the issue. Regarding the hostname, it's specified multiple times in the question, probably you just missed it multiple times. – watch-this Jan 25 '23 at 01:41