MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
770 stars 438 forks source link

Mariadb is not working #481

Closed dswtpvtltd closed 1 year ago

dswtpvtltd commented 1 year ago

Os: macos ventura docker version: 4.15.0 (93002)

I am setting up mariadb by using docker-compose.yml and docker-sync.yml

I am trying to connect mysql on docker terminal by using username: root and password: 123456 used in docker-compose.yml file.

# mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
# 

in my site code I am using details: host: db username: root password: 123456 database: mydatabase

My docker-compose.yml


services:
  db:
    image: mariadb:10.4
    ports:
      - "3307:3306"
    environment:
      - MYSQL_DATABASE=mydatabase
      - MYSQL_ROOT_PASSWORD=123456
    volumes:
      - ./dockerfile/phpfpm/db-data:/var/lib/mysql
    networks:
      net:

  web:
    build:
      context: .
      dockerfile: ./dockerfile/phpfpm/Dockerfile.web
    hostname: ${COMPOSE_PROJECT_NAME}-web
    ports:
      - "${HTTPS_PORT}:80"
    restart: always
    volumes:
      - ./src/anyboat-com-au:/var/www/html
    networks:
      net:
    depends_on:
      - db
      - cache
      - session
      - search

  search:
    image: elasticsearch:7.17.6
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    hostname: search
    environment:
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms1g -Xmx1g
      - xpack.security.enabled=false
      - bootstrap.system_call_filter=false
    networks:
      net:

  cache:
    image: redis:6.2
    restart: always
    ports:
      - "6380:6379"
    hostname: cache
    networks:
      net:

  session:
    image: redis:6.2
    restart: always
    ports:
      - "6381:6379"
    hostname: session
    networks:
      net:

  varnish:
    build:
      context: .
      dockerfile: ./dockerfile/phpfpm/Dockerfile.varnish
      args:
        VARNISH_CONFIG: ${VARNISH_CONFIG}
    hostname: varnish
    ports:
      - "${HTTP_PORT}:6081"
    networks:
      net:
    depends_on:
      - web

networks:
  net:
grooverdan commented 1 year ago

note in #447, that especially using MacOS that you should be using named volumes. Check your docker /compose logs for the mariadb container show it to be running.

MacOS runs the container in a VM so a unix socket (default) authentication isn't going to pass through to the VM).

In your compose you've exposed it as port 3307.

From from MacOS:

$ mysql --port 3307 --user root --host 127.0.0.1 --protocol tcp -p

From existing documents it will be on host 127.0.0.1 but if needed inspect the container to examine its networking setup.

dswtpvtltd commented 1 year ago

note in #447, that especially using MacOS that you should be using named volumes. Check your docker /compose logs for the mariadb container show it to be running.

MacOS runs the container in a VM so a unix socket (default) authentication isn't going to pass through to the VM).

In your compose you've exposed it as port 3307.

From from MacOS:

$ mysql --port 3307 --user root --host 127.0.0.1 --protocol tcp -p

From existing documents it will be on host 127.0.0.1 but if needed inspect the container to examine its networking setup.

Thanks for your reply. I tried above command but it is still now working I am getting following response

mysql --port 3307 --user root --host 127.0.0.1 --protocol tcp -p

Enter password: ERROR 2002 (HY000): Can't connect to MySQL server on '127.0.0.1' (115)

Please check the following image URl for inspect

Screenshot 2022-12-21 at 10 39 10 AM

Log for mariaDB is following:

2022-12-20 11:24:12 2022-12-20 05:54:12+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.4.27+maria~ubu2004 started.
2022-12-20 11:24:15 2022-12-20 05:54:15+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-12-20 11:24:15 2022-12-20 05:54:15+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.4.27+maria~ubu2004 started.
2022-12-20 11:24:16 2022-12-20 05:54:16+00:00 [Note] [Entrypoint]: MariaDB upgrade (mysql_upgrade) required, but skipped due to $MARIADB_AUTO_UPGRADE setting
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] mysqld (mysqld 10.4.27-MariaDB-1:10.4.27+maria~ubu2004) starting as process 1 ...
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Using Linux native AIO
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Uses event mutexes
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Number of pools: 1
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Using SSE2 crc32 instructions
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Warning] InnoDB: Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB.
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: You can disable Linux Native AIO by setting innodb_use_native_aio = 0 in my.cnf
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Warning] InnoDB: Linux Native AIO disabled.
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Completed initialization of buffer pool
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-12-20 11:24:16 2022-12-20  5:54:16 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=9511151878
2022-12-20 11:24:17 2022-12-20  5:54:17 0 [Note] InnoDB: Starting final batch to recover 27 pages from redo log.
2022-12-20 11:24:17 2022-12-20  5:54:17 0 [ERROR] [FATAL] InnoDB: Trying to read page number 4 in space 9302, space name anyboat_m2/FTS_00000000000028bd_000000000000674d_INDEX_4, which is outside the tablespace bounds. Byte offset 0, len 16384
2022-12-20 11:24:17 221220  5:54:17 [ERROR] mysqld got signal 6 ;
2022-12-20 11:24:17 This could be because you hit a bug. It is also possible that this binary
2022-12-20 11:24:17 or one of the libraries it was linked against is corrupt, improperly built,
2022-12-20 11:24:17 or misconfigured. This error can also be caused by malfunctioning hardware.
2022-12-20 11:24:17 
2022-12-20 11:24:17 To report this bug, see https://mariadb.com/kb/en/reporting-bugs
2022-12-20 11:24:17 
2022-12-20 11:24:17 We will try our best to scrape up some info that will hopefully help
2022-12-20 11:24:17 diagnose the problem, but since we have already crashed, 
2022-12-20 11:24:17 something is definitely wrong and this may fail.
2022-12-20 11:24:17 
2022-12-20 11:24:17 Server version: 10.4.27-MariaDB-1:10.4.27+maria~ubu2004
2022-12-20 11:24:17 key_buffer_size=134217728
2022-12-20 11:24:17 read_buffer_size=2097152
2022-12-20 11:24:17 max_used_connections=0
2022-12-20 11:24:17 max_threads=102
2022-12-20 11:24:17 thread_count=0
2022-12-20 11:24:17 It is possible that mysqld could use up to 
2022-12-20 11:24:17 key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 760270 K  bytes of memory
2022-12-20 11:24:17 Hope that's ok; if not, decrease some variables in the equation.
2022-12-20 11:24:17 
2022-12-20 11:24:17 Thread pointer: 0x0
2022-12-20 11:24:17 Attempting backtrace. You can use the following information to find out
2022-12-20 11:24:17 where mysqld died. If you see no messages after this, something went
2022-12-20 11:24:17 terribly wrong...
2022-12-20 11:24:17 stack_bottom = 0x0 thread_stack 0x49000
2022-12-20 11:24:17 mysqld(my_print_stacktrace+0x32)[0x4000e44a62]
2022-12-20 11:24:17 mysqld(handle_fatal_signal+0x55d)[0x40008d953d]
2022-12-20 11:24:17 /lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x4003c50420]
2022-12-20 11:24:17 /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x4003fd900b]
2022-12-20 11:24:17 /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x4003fb8859]
2022-12-20 11:24:17 mysqld(+0x5bc251)[0x40005bc251]
2022-12-20 11:24:17 mysqld(+0x5d2132)[0x40005d2132]
2022-12-20 11:24:17 mysqld(+0xd2ec09)[0x4000d2ec09]
2022-12-20 11:24:17 mysqld(+0xd30323)[0x4000d30323]
2022-12-20 11:24:17 mysqld(+0xc097de)[0x4000c097de]
2022-12-20 11:24:17 mysqld(+0x5b4a94)[0x40005b4a94]
2022-12-20 11:24:17 mysqld(+0xb9ae90)[0x4000b9ae90]
2022-12-20 11:24:17 mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x70)[0x40008dcd30]
2022-12-20 11:24:17 mysqld(+0x6e3735)[0x40006e3735]
2022-12-20 11:24:17 mysqld(_Z11plugin_initPiPPci+0x8f6)[0x40006e4a46]
2022-12-20 11:24:17 mysqld(+0x6024f4)[0x40006024f4]
2022-12-20 11:24:17 mysqld(_Z11mysqld_mainiPPc+0x406)[0x40006082d6]
2022-12-20 11:24:17 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x4003fba083]
2022-12-20 11:24:17 mysqld(_start+0x2e)[0x40005fc32e]
2022-12-20 11:24:17 The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
2022-12-20 11:24:17 information that should help you find out what is causing the crash.
2022-12-20 11:24:17 Writing a core file...
2022-12-20 11:24:17 Working directory at /var/lib/mysql
2022-12-20 11:24:17 Resource Limits:
2022-12-20 11:24:17 Limit                     Soft Limit           Hard Limit           Units     
2022-12-20 11:24:17 Max cpu time              unlimited            unlimited            seconds   
2022-12-20 11:24:17 Max file size             unlimited            unlimited            bytes     
2022-12-20 11:24:17 Max data size             unlimited            unlimited            bytes     
2022-12-20 11:24:17 Max stack size            8388608              unlimited            bytes     
2022-12-20 11:24:17 Max core file size        0                    unlimited            bytes     
2022-12-20 11:24:17 Max resident set          unlimited            unlimited            bytes     
2022-12-20 11:24:17 Max processes             unlimited            unlimited            processes 
2022-12-20 11:24:17 Max open files            1048576              1048576              files     
2022-12-20 11:24:17 Max locked memory         65536                65536                bytes     
2022-12-20 11:24:17 Max address space         unlimited            unlimited            bytes     
2022-12-20 11:24:17 Max file locks            unlimited            unlimited            locks     
2022-12-20 11:24:17 Max pending signals       15275                15275                signals   
2022-12-20 11:24:17 Max msgqueue size         819200               819200               bytes     
2022-12-20 11:24:17 Max nice priority         0                    0                    
2022-12-20 11:24:17 Max realtime priority     0                    0                    
2022-12-20 11:24:17 Max realtime timeout      unlimited            unlimited            us        
2022-12-20 11:24:17 Core pattern: core
2022-12-20 11:24:17 
2022-12-20 11:24:17 Kernel version: Linux version 5.15.49-linuxkit (root@buildkitsandbox) (gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, GNU ld (GNU Binutils) 2.35.2) #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022
2022-12-20 11:24:17 
2022-12-20 11:24:17 qemu: uncaught target signal 6 (Aborted) - core dumped
grooverdan commented 1 year ago

I searched though https://jira.mariadb.org and have been unable to find and existing bug report.

Can you please create a new bug report. I assume anyboat_m2 corresponds to a tablename in some form. Include show create table {tablename} in your bug report if you have a definition from somewhere that's not corrupted.

If you are willing to share privately your datadir zipped up for MariaDB developers that would also aid debugging this. use the ftp server and make a note its there in your bug report.

dswtpvtltd commented 1 year ago

I searched though https://jira.mariadb.org and have been unable to find and existing bug report.

Can you please create a new bug report. I assume anyboat_m2 corresponds to a tablename in some form. Include show create table {tablename} in your bug report if you have a definition from somewhere that's not corrupted.

If you are willing to share privately your datadir zipped up for MariaDB developers that would also aid debugging this. use the ftp server and make a note its there in your bug report.

Thanks you very much to reply me. Sir, I am unable to connect to mariaDB either by terminal or by any GUI tools it is not possble to create database yet. and As I know that when we pass database by environment: - MYSQL_DATABASE=mydatabase, it will create an empty database. current databases it is empty. there are no any table or data and I have to create this new database.

grooverdan commented 1 year ago

You're unable to connect because MariaDB didn't start. MariaDB failed because of what was in the logs, which was as a result of a pre-mariadb-10.4 data stored in ./dockerfile/phpfpm/db-data. Because this isn't an empty directory its not even going to try to create a new database.

https://docs.docker.com/desktop/mac/ recommends using named volume/data container for database volumes. Is there are reason you aren't doing this? With a new project seems like a good time to use a named volume rather than a local path.