Skip to content

Instantly share code, notes, and snippets.

@feltnerm
Last active February 21, 2023 08:36
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save feltnerm/bb6e23f531803896ca1e to your computer and use it in GitHub Desktop.
Save feltnerm/bb6e23f531803896ca1e to your computer and use it in GitHub Desktop.
Docker + MySQL + `lower_case_table_names=1`
# Build the base image
docker build -t widen/db .
# Run the container
docker run --name $container_name --net=host \
-e MYSQL_USER=$mysql_user \
-e MYSQL_PASSWORD=$mysql_password \
-e MYSQL_DATABASE=$mysql_database \
-e MYSQL_ROOT_PASSWORD=$mysql_root_password \
-d widen/db
# Import SQL
mysql --user=$user --password=$pass --host=$HOST $db < $sql_dump
FROM mysql
ADD my.cnf /etc/mysql/my.cnf
CMD ["mysqld", "--datadir=/var/lib/mysql", "--user=mysql"]
[mysqld]
bind-address=0.0.0.0
# http://www.percona.com/blog/2008/05/31/dns-achilles-heel-mysql-installation/
skip_name_resolve
general_log_file = /var/lib/mysql.log
general_log = 1
lower_case_table_names = 1
@LoicMahieu
Copy link

If anyone interested, you can pass extra options to deamon like this:

docker run \
  -d \
  -p 3306:3306 \
  mysql:5.6 \
  mysqld --lower_case_table_names=1

@Nxtra
Copy link

Nxtra commented Jul 11, 2018

How to pass lower_case_table_names=1 to a docker-compose.yml ?

@deleze
Copy link

deleze commented Aug 31, 2018

With docker, it seems to depends on your host OS.
On Mac I use --lower_case_table_names=0 . It's strange that is linked to the file system of the host.

mysql:
    container_name: vpdev-mysql
    image: mysql:5.7
    command: --lower_case_table_names=0
    environment:
      - MYSQL_ROOT_PASSWORD=root
    volumes:
      - ./data/initdb.d:/docker-entrypoint-initdb.d
      - ./data/mysql:/var/lib/mysql
    ports:
      - "3308:3306"

@fc4soda
Copy link

fc4soda commented Nov 20, 2018

CentOS 7 use command: --lower_case_table_names=0 works!
Using docker 18.03.1-ce and docker-compose 1.22.0

@Akazm
Copy link

Akazm commented Oct 10, 2022

How to do it in 2022?

@PopMishima
Copy link

docker-compose.yml

services:
  mariadb:
    command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--lower_case_table_names=1']
    image: mariadb
    restart: unless-stopped
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment