Configure Mysql in Docker container

Asked

Viewed 699 times

0

When I take an SQL file of about 80 Mb and try to dump it in Mysql Workbench

He gives:

Error Code: 2006. Mysql server has Gone away

My Docker-Compose configuration looks like this:

version: "3.3"
services:
  mysql:
    image: mysql:8.0.1
    container_name: mysql
    volumes:     
      - ./etc/mysql/my.cnf:/etc/mysql/my.cnf  
    environment: 
      MYSQL_ROOT_PASSWORD: "123"
    ports:
      - '3306:3306'
    volumes:
      - mysql-db:/var/lib/mysql  
volumes:
  mysql-db:

My file etc/mysql/my.cnf in local folder and not mysql is like this:

[client]
port      = 3306
socket      = /var/run/mysqld/mysqld.sock

[safe_mysqld]
err-log      = /var/log/mysql/mysql.err

[mysqld]
server-id=10
log-bin=/var/log/mysql/mysql-bin.log
binlog-do-db=pop
binlog-ignore-db=mailstats,mysql,pop.bak,radius,radius.bak,test

user      = mysql
pid-file   = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port      = 3306
log      = /var/log/mysql.log
basedir      = /usr
datadir      = /var/lib/mysql
tmpdir      = /tmp
language   = /usr/share/mysql/english
skip-locking

# key-buffer define quanto de memória será armazenado para
# gravar dados de consultas do MySQL. Quanto maior a quantidade
# de memória disponível, melhor será o desempenho do servidor
set-variable    = key_buffer=312M

set-variable    = max_allowed_packet=64M

# table_cache é muito importante, este número deve ser o dobro
# do número definido pela variável max_connections
set-variable    = table_cache=20000

set-variable    = sort_buffer=1M
set-variable    = record_buffer=1M
set-variable    = myisam_sort_buffer_size=64M
set-variable    = thread_cache=8
set-variable    = thread_concurrency=8

# max_connections vai definir quantos sub-processos e 
# consequentemente quantas conexões seu MySQL suportará
# simultaneamente. Por incrível que pareça, quanto maior este
# número, menor será o load do seu server. Tente restringir este
# para um número baixo e você verá que loucura está fazendo
set-variable    = max_connections=10000

set-variable    = net_write_timeout=30
set-variable    = connect_timeout=2
set-variable    = wait_timeout=30

# Read the manual if you want to enable InnoDB!
skip-innodb

[mysqldump]
quick
set-variable   = max_allowed_packet=64M

[mysql]

[isamchk]
set-variable   = key_buffer=64M # era 16M

I would like to configure for my mysql Docker accept large files

My complete project is here

1 answer

0

Friend, by the description of the error, this usually occurs when the server exceeded the time limit and closed the connection or when the package size exceeded the maximum size of the packets that can travel in Mysql threads. In your case when doing database Restore.

Try the following:

Change the value of this variable:

set-variable    = wait_timeout=30

For a value that can supply your upload time. and also change this other variable:

set-variable    = max_allowed_packet=64M

For a value compatible with the size of your package. In your case, above 80M.

Make the changes to etc/mysql/my.cnf and restart the Mysql database server so the changes become valid.

  • Even changing, when I go to Workbench continues with this value '4194304' when I give the command 'SELECT @@max_allowed_packet; and then continues giving this problem `

Browser other questions tagged

You are not signed in. Login or sign up in order to post.