Last active
November 8, 2024 07:25
-
-
Save feltnerm/bb6e23f531803896ca1e to your computer and use it in GitHub Desktop.
Docker + MySQL + `lower_case_table_names=1`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mysql | |
ADD my.cnf /etc/mysql/my.cnf | |
CMD ["mysqld", "--datadir=/var/lib/mysql", "--user=mysql"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
How to do it in 2022?
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
...
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 ...
Man! man! you saved my ass! have been dealing with this for days with mysql:5.7.22 docker image. did all settings in the my.cnf, and all the config files and it never worked until i tried running the command you kept in the docker compose.
Thanks bro. Chatgpt couldnt help:)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CentOS 7 use
command: --lower_case_table_names=0
works!Using docker 18.03.1-ce and docker-compose 1.22.0