Could not create tables: (MySQLdb._exceptions.OperationalError | MySQL tracker store

Encountering below error when starting rasa server using docker-compose up:

*rasa.core.tracker_store - Could not create tables: (MySQLdb._exceptions.OperationalError) (1045, "Access denied for user 'root'@'172.18.0.3' (using password: NO)")*

Relevant portion of docker-compose.yml

  mysql:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - .data/mysql:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: rasa

Relevant portion of endpoints.yml

tracker_store:
    type: SQL
    dialect: "mysql"  # the dialect used to interact with the db
    url: "mysql://mysql:3306"  # (optional) host of the sql db
    db: rasa  # path to your db
    username:  root # username used for authentication
    password:  example # password used for authentication

There were two problems:

  1. My docker was creating a root user without password in MySQL
  2. Rasa was not using the password provided in the endpoints.yml

I forced docker to create root user with password by editing docker-compose.yml :

  mysql:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - .data/mysql:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_ALLOW_EMPTY_PASSWORD: "No"
      MYSQL_DATABASE: rasa

I made below edits in endpoints.yml to use the password provided:

tracker_store:
    type: SQL
    dialect: "mysql"  # the dialect used to interact with the db
    url: "mysql://root:example@mysql:3306/rasa"  # (optional) host of the sql db
    #db: rasa  # path to your db
    #username:  rasa # username used for authentication
    #password:  welcome # password used for authentication

After above two changes, rasa was successfully connecting to MySQL:

Logged a bug for this: