0

I am trying to configure my Django + MySQL(8.0.26) project on Ubuntu 20.04 based AWS EC2 server with Docker Compose. However, MySQL database container is not working because of lower_case_table_names. These are a few solutions solution1, solution2, solution3 which I've already tried but have not been able to find the solution.

I have created a sample project based on this YouTube tutorial which is successfully running on my local machine(macOS 11.4).

docker-compose.yml

version: '3.8'

services: 
  db:
    image: mysql:8.0.26
    restart: always
    command: --lower_case_table_names=1
    environment:
      - MYSQL_DATABASE=tutorialdb
      - MYSQL_USER=chitrang
      - MYSQL_PASSWORD=test123
      - MYSQL_ROOT_PASSWORD=test123
    ports:
      - "3307:3306"
    volumes:
      - ./dbdata:/var/lib/mysql
  backend:
    build: .
    command: python manage.py runserver 0.0.0.0:8000  
    ports:
      - 8000:8000
    volumes:
      - .:/app
    depends_on:
      - db

Error Log:

db_1       | 2021-08-20 01:01:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1       | 2021-08-20 01:01:50+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1       | 2021-08-20 01:01:50+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1       | 2021-08-20T01:01:51.247142Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 1
db_1       | 2021-08-20T01:01:52.809303Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db_1       | 2021-08-20T01:01:56.262851Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db_1       | 2021-08-20T01:01:56.320513Z 1 [ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('1') and data dictionary ('2').
db_1       | 2021-08-20T01:01:56.321126Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
db_1       | 2021-08-20T01:01:56.321630Z 0 [ERROR] [MY-010119] [Server] Aborting
db_1       | 2021-08-20T01:01:56.867684Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.26)  MySQL Community Server - GPL.

I have tried to set all the three possible values 0|1|2 for lower_case_table_names in a docker-compose.yml file but error message is similar each time.

I guess solution could be simple but since this my first Backend + DevOps project I might not able to figure it out easily. Moreover, it seems this issue is common and has been faced by many developers so in my opinion either MySQL or Ubuntu team should have resolved it.

Chitrang
  • 5,097
  • 1
  • 35
  • 58

1 Answers1

0

Try this, It worked for me:

https://gist.github.com/feltnerm/bb6e23f531803896ca1e

version: '3.8'

services: 
  db:
    image: mysql:8.0.26
    restart: always
    command: --lower_case_table_names=0
    environment:
      - MYSQL_DATABASE=tutorialdb
      - MYSQL_USER=chitrang
      - MYSQL_PASSWORD=test123
      - MYSQL_ROOT_PASSWORD=test123
    ports:
      - "3307:3306"
    volumes:
      - ./data/initdb.d:/docker-entrypoint-initdb.d
      - ./data/mysql:/var/lib/mysql
  backend:
    build: .
    command: python manage.py runserver 0.0.0.0:8000  
    ports:
      - 8000:8000
    volumes:
      - .:/app
    depends_on:
      - db
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 15 '22 at 17:01