Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker. MySQL image. Can't change my.cnf file

I have such a docker-compose.yml:

    database:
        container_name: test_db
        image: mysql:5.7
        volumes:
            - ./docker/my.cnf:/etc/my.cnf
        environment:
            - "MYSQL_ROOT_PASSWORD=root"
            - "MYSQL_DATABASE=test_db"
        ports:
            - "3306:3306"
        volumes:
          - test_db_data:/var/lib/mysql

volumes:
    test_db_data:

and I want to edit the sql_mode.

./docker/my.cnf contains:

[mysqld]
sql_mode=""

But when I connect to db from my local machine and run SELECT @@sql_mode; I receive:

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

What am I doing wrong?

like image 806
D.R. Avatar asked Nov 19 '17 07:11

D.R.


1 Answers

You can add this to your db service:

command: --sql_mode=""

so its:

    database:
    container_name: test_db
    image: mysql:5.7
    volumes:
        - ./docker/my.cnf:/etc/my.cnf
    environment:
        - "MYSQL_ROOT_PASSWORD=root"
        - "MYSQL_DATABASE=test_db"
    ports:
        - "3306:3306"
    volumes:
      - test_db_data:/var/lib/mysql
    command: --sql_mode=""
like image 56
Brad Avatar answered Oct 08 '22 08:10

Brad