mariaDB crush and didn't restart - docker

my company develop db crushed unexpectedly and it didn't restart or start now
I backup the file in /var/lib/mysql and clone them to my local to try recover it.
I lunched the same version of mariaDB by docker
the setting I used were here
docker-compose.yml
version: '3.1'
services:
db:
image: mariadb:10.3.25
restart: always
volumes:
- ./mariadb/data/:/var/lib/mysql
- ./mariadb/my.cnf:/etc/mysql/my.cnf
- ./mariadb/logs:/logs
environment:
MYSQL_ROOT_PASSWORD: example
my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8
[mysqld]
event_scheduler=ON
default-time_zone = '+8:00'
port = 3306
socket = /tmp/mysql.sock
back_log = 50
max_connections = 100
max_connect_errors = 10
table_open_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 2
query_cache_size = 64M
query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = InnoDB
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M
tmp_disk_table_size = 1G
log-bin=mysql-bin
expire-logs-days=60
binlog_format=mixed
slow_query_log
long_query_time = 5
log-error=/logs/error.log
server-id = 1
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam-recover-options
innodb_data_home_dir = /var/lib/mysql
innodb_buffer_pool_size=1G
innodb_data_file_path = ibdata1:12M;ibdata2:74M:autoextend
innodb_log_group_home_dir = /var/lib/mysql
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_thread_concurrency=5
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size=8M
innodb_log_file_size=150M
innodb_log_files_in_group=3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout=50
init_connect='SET clooation_connection = utf8_unicode_ci'
init_connect='SET NAMES uft8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
init_file=/opt/init.sql
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
default-character-set = utf8
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
after install it I enter into the container and implement mysql command, which was the message i got
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
and the log of db container were
2022-05-27 11:51:01+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.3.25+maria~focal started.
2022-05-27 11:51:01+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-05-27 11:51:01+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.3.25+maria~focal started.
2022-05-27 11:51:01 0 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2022-05-27 11:51:01 0 [Note] mysqld (mysqld 10.3.25-MariaDB-1:10.3.25+maria~focal-log) starting as process 1 ...
mysqld: Can't create file '/logs/error.log' (errno: 13 "Permission denied")
2022-05-27 11:51:01 0 [Note] InnoDB: Using Linux native AIO
2022-05-27 11:51:01 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-05-27 11:51:01 0 [Note] InnoDB: Uses event mutexes
2022-05-27 11:51:01 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-05-27 11:51:01 0 [Note] InnoDB: Number of pools: 1
2022-05-27 11:51:01 0 [Note] InnoDB: Using SSE2 crc32 instructions
2022-05-27 11:51:01 0 [Note] InnoDB: Initializing buffer pool, total size = 1G, instances = 8, chunk size = 128M
2022-05-27 11:51:01 0 [Note] InnoDB: Completed initialization of buffer pool
2022-05-27 11:51:01 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-05-27 11:51:01 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=42671766726
2022-05-27 11:51:05 0 [Note] InnoDB: 1 transaction(s) which must be rolled back or cleaned up in total 4 row operations to undo
2022-05-27 11:51:05 0 [Note] InnoDB: Trx id counter is 59006964
2022-05-27 11:51:05 0 [Note] InnoDB: Starting final batch to recover 6297 pages from redo log.
2022-05-27 11:51:07 0 [Note] InnoDB: Last binlog file './mysql-bin.000230', position 168122090
I waited for a period of time and the program was freeze here
Is it running recovery program? or just stuck here ?
How can I do for recovery and let it work well ?

Related

Why does MariaDB on Docker runs much slower than 'native' MariaDB package on the same Synology machine?

There is a Synology DS1621xs+ (equiped with NVMe SSD cache and 24 GB RAM).
OS: Synology DSM 7.1
File System: btrfs
Docker version: 20.10.3
There is a MariaDB10 server running on Docker on this machine.
An identical database is running on the 'native' Synology MariaDB10 package on the same machine. (Dumped and copied from the Docker instance.)
Queries on the database of the 'native' MariaDB10 package run much faster than on the docker instance. Difference is at least 2.5x, but on some queries it is 20x.
What might be the reason of this huge perfomance difference, why are the queries slower on Docker than on the Synology Package version of MariaDB?
Dockerinfo:
Client:
Context: default
Debug Mode: false
Server:
Containers: 10
Running: 7
Paused: 0
Stopped: 3
Images: 36
Server Version: 20.10.3
Storage Driver: btrfs
Build Version: Btrfs v4.0
Library Version: 101
Logging Driver: db
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs db fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3fa00912415f3e9c6f82dd72119179d599efd13b
runc version: 31cc25f16f5eba4d0f53e35374532873744f4b31
init version: ed96d00 (expected: de40ad0)
Security Options:
apparmor
Kernel Version: 4.4.180+
Operating System: (containerized)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 23.25GiB
Name: NAS
ID: ZLGI:KUWA:HOGC:3J6W:B6NJ:CZLJ:ZQP2:HAG5:3DP6:OEPX:5WRW:IHAJ
Docker Root Dir: /volume2/#docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No kernel memory TCP limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No blkio weight support
WARNING: No blkio weight_device support
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
`
MariaDB container log:
2022-11-19T08:55:19.209130033Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Buffer pool(s) load completed at 221119 9:55:19
2022-11-19T08:55:19.174115217Z stdout Version: '10.6.5-MariaDB-1:10.6.5+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
2022-11-19T08:55:19.174011946Z stdout 2022-11-19 9:55:19 0 [Note] mysqld: ready for connections.
2022-11-19T08:55:19.167072919Z stdout 2022-11-19 9:55:19 0 [Warning] 'proxies_priv' entry '#% root#mariadb-copy' ignored in --skip-name-resolve mode.
2022-11-19T08:55:19.163349561Z stdout 2022-11-19 9:55:19 0 [Note] Server socket created on IP: '::'.
2022-11-19T08:55:19.163211778Z stdout 2022-11-19 9:55:19 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-11-19T08:55:19.161820288Z stdout 2022-11-19 9:55:19 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2022-11-19T08:55:19.149901116Z stdout 2022-11-19 9:55:19 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-11-19T08:55:19.149840357Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-11-19T08:55:19.149391807Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: 10.6.5 started; log sequence number 3282096825; transaction id 7204
2022-11-19T08:55:19.148296829Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-11-19T08:55:19.148223400Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-11-19T08:55:19.148147151Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-11-19T08:55:19.147243337Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: 128 rollback segments are active.
2022-11-19T08:55:19.086673922Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Completed initialization of buffer pool
2022-11-19T08:55:19.085986215Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-11-19T08:55:19.085469623Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Using Linux native AIO
2022-11-19T08:55:19.068551244Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-11-19T08:55:19.068528556Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Number of pools: 1
2022-11-19T08:55:19.068487467Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Using transactional memory
2022-11-19T08:55:19.068374374Z stdout 2022-11-19 9:55:19 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-11-19T08:55:19.049836283Z stdout 2022-11-19 9:55:19 0 [Note] mysqld (server 10.6.5-MariaDB-1:10.6.5+maria~focal) starting as process 1 ...
2022-11-19T08:55:18.900158637Z stdout 2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.3.14+maria~bionic started.
2022-11-19T08:55:18.892594609Z stdout 2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-11-19T08:55:18.738312960Z stdout 2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.3.14+maria~bionic started.
MariaDB changed innodb_flush_method=O_DIRECT in 10.6 to aid the high end performance. As such MariaDB-10.6 is much more reliant on a innodb_buffer_pool_size and innodb_log_file_size to gain read/write performance.
As a work around, test 10.6 with innodb_flush_method=fsync. btrfs is significantly newer than today than in kernel 4.4.0 so maybe its O_DIRECT paths weren't as performing in 4.4.0.
It could also be MDEV-29967 broken linear read ahead that we're working hard to fix before the next release.
It might also be the 10.6 statistics are different try a recalculation using ANALYZE TABLES.
There's a couple of btrfs links/suggestions in this link.
Or it could be something totally different requiring:
careful measurement and breakdown of individual queries and their execution.
elimination of local environment (running a 10.3 version in the container of the same version/configuration as the local package).

mariadb (in docker) corruption. Fix or reset database?

I am using the official mariadb docker image, and after updating to latest version (10.5.8), I started getting errors about corruption (see logs below). Since this persists when I downgrade to earlier mariadb versions, I guess it's a database corruption?
Is there a way to fix it? and if not, how do I just reset the database (it's not the end of the world to lose data in database, but it is if the mariadb container does not start to work).
logs (this repeats):
2020-11-18 15:45:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
2020-11-18 15:45:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-11-18 15:45:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
2020-11-18 15:45:36 0 [Note] mysqld (mysqld 10.5.8-MariaDB-1:10.5.8+maria~focal) starting as process 1 ...
2020-11-18 15:45:36 0 [Note] InnoDB: Using Linux native AIO
2020-11-18 15:45:36 0 [Note] InnoDB: Uses event mutexes
2020-11-18 15:45:36 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-11-18 15:45:36 0 [Note] InnoDB: Number of pools: 1
2020-11-18 15:45:36 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-11-18 15:45:36 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-11-18 15:45:36 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-11-18 15:45:36 0 [Note] InnoDB: Completed initialization of buffer pool
2020-11-18 15:45:36 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-11-18 15:45:36 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=20174219501,20174219501
2020-11-18 15:45:36 0 [Note] InnoDB: Starting final batch to recover 3205 pages from redo log.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Not applying INSERT_REUSE_REDUNDANT due to corruption on [page id: space=0, page number=2062]
2020-11-18 15:45:36 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore corruption.
2020-11-18 15:45:36 0 [ERROR] InnoDB: Plugin initialization aborted with error Data structure corruption
2020-11-18 15:45:36 0 [Note] InnoDB: Starting shutdown...
2020-11-18 15:45:37 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-11-18 15:45:37 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-11-18 15:45:37 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-11-18 15:45:37 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2020-11-18 15:45:37 0 [ERROR] Aborting
And using this docker-compose.yaml:
hass_db:
image: mariadb:latest
# image: mariadb:10.5.4
# image: mariadb:10.4.14
container_name: hass_db
environment:
MYSQL_ROOT_PASSWORD: Maria4sud0
MYSQL_DATABASE: homeassistant
MYSQL_USER: homeassistant
MYSQL_PASSWORD: Maria4HAss
restart: on-failure
volumes:
- /mnt/data/docker/hass_db:/var/lib/mysql
networks:
mynet:
ipv4_address: 172.11.0.7

docker-compose mariadb docker-entrypoint-initdb.d sql is not executed

I am attempting to have my docker db container automatically populate the database with a dataset when created. According to the mariadb documentation, there is an docker-entrypoint-initdb.d folder in the volume that can be used for this purpose.
I set up my docker-compose.yml file to mirror examples that I have found on StackOverflow, but am still unable to get my SQL scripts to execute. Here are the relevant pieces of my docker-compose.yml file:
version: '3.6'
services:
db:
image: mariadb:10.5.4-focal
container_name: db
volumes:
- ./cms/conf/mysql/data/:/var/lib/mysql/:rw
- ./cms/sql/:/docker-entrypoint-initdb.d/:ro
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=root
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=wordpress
restart: always
adminer:
image: adminer:4.7.7-standalone
container_name: adminer
links:
- db
ports:
- 8080:8080
restart: always
Next to the docker-compose.yml file, I have a cms/sql/init.sql file with the following contents:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `test`;
Prior to each test iteration, I clean up any old/cached Docker content:
$ docker-compose down -v I've found this doesn't actually remove the db volumes. Running a docker volume ls still shows past volumes present.
$ docker volume prune This clears out the volumes. Running docker volume ls after running this shows an empty list.
$ rm -rf ./cms/conf/mysql This cleans out any actual filesystem changes that the db container made.
$ docker-compose up -d --build To rebuild the containers. This should trigger my initialization SQL scripts.
Docker runs, and the db container gets successfully created. I am able to access the adminer container running on localhost:8080. I am able to log in as the root user with the password specified in the docker-compose.yml file.
The Adminer interface shows the standard MySQL databases (information_schema, mysql, performance_schema) and additionally shows the wordpress database defined in the MYSQL_DATABASE value of the docker-compose.yml file. But my test database from the init.sql is nowhere to be found.
I found some other similar StackOverflow questions that have had similar problems. I've followed the accepted answers, and am still unable to get any SQL scripts to get executed.
docker-compose.yml, postgress, how to setup db, tables and prepop in an init.sql file?
Issue with docker compose initial DB setup once
mySQL init scripts not running with docker-compose
Create database on docker-compose startup
Here's the Docker log from my db container. I didn't see anything that looked strange; no error messages about initialization, etc:
2020-07-15 19:21:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Initializing database files
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Database files initialized
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Starting temporary server
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Waiting for server startup
2020-07-15 19:21:47 0 [Note] mysqld (mysqld 10.5.4-MariaDB-1:10.5.4+maria~focal) starting as process 107 ...
2020-07-15 19:21:47 0 [Note] InnoDB: Using Linux native AIO
2020-07-15 19:21:47 0 [Note] InnoDB: Uses event mutexes
2020-07-15 19:21:47 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-15 19:21:47 0 [Note] InnoDB: Number of pools: 1
2020-07-15 19:21:47 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-07-15 19:21:47 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-07-15 19:21:47 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-07-15 19:21:47 0 [Note] InnoDB: Completed initialization of buffer pool
2020-07-15 19:21:47 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-07-15 19:21:48 0 [Note] InnoDB: 128 rollback segments are active.
2020-07-15 19:21:48 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-07-15 19:21:48 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-07-15 19:21:49 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-07-15 19:21:49 0 [Note] InnoDB: 10.5.4 started; log sequence number 45041; transaction id 21
2020-07-15 19:21:49 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-07-15 19:21:49 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-07-15 19:21:49 0 [Note] InnoDB: Buffer pool(s) load completed at 200715 19:21:49
2020-07-15 19:21:49 0 [Warning] 'user' entry 'root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'user' entry '#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Note] Reading of all Master_info entries succeeded
2020-07-15 19:21:49 0 [Note] Added new Master_info '' to hash table
2020-07-15 19:21:49 0 [Note] mysqld: ready for connections.
Version: '10.5.4-MariaDB-1:10.5.4+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
2020-07-15 19:21:49+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
2020-07-15 19:21:58 5 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating database wordpress23
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating user root
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%'
2020-07-15 19:21:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:21:35+00:00 [Note] [Entrypoint]: Initializing database files
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Database files initialized
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Starting temporary server
2020-07-15 19:21:47+00:00 [Note] [Entrypoint]: Waiting for server startup
2020-07-15 19:21:47 0 [Note] mysqld (mysqld 10.5.4-MariaDB-1:10.5.4+maria~focal) starting as process 107 ...
2020-07-15 19:21:47 0 [Note] InnoDB: Using Linux native AIO
2020-07-15 19:21:47 0 [Note] InnoDB: Uses event mutexes
2020-07-15 19:21:47 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-15 19:21:47 0 [Note] InnoDB: Number of pools: 1
2020-07-15 19:21:47 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-07-15 19:21:47 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-07-15 19:21:47 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-07-15 19:21:47 0 [Note] InnoDB: Completed initialization of buffer pool
2020-07-15 19:21:47 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-07-15 19:21:48 0 [Note] InnoDB: 128 rollback segments are active.
2020-07-15 19:21:48 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-07-15 19:21:48 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-07-15 19:21:49 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-07-15 19:21:49 0 [Note] InnoDB: 10.5.4 started; log sequence number 45041; transaction id 21
2020-07-15 19:21:49 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-07-15 19:21:49 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-07-15 19:21:49 0 [Note] InnoDB: Buffer pool(s) load completed at 200715 19:21:49
2020-07-15 19:21:49 0 [Warning] 'user' entry 'root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'user' entry '#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:49 0 [Note] Reading of all Master_info entries succeeded
2020-07-15 19:21:49 0 [Note] Added new Master_info '' to hash table
2020-07-15 19:21:49 0 [Note] mysqld: ready for connections.
Version: '10.5.4-MariaDB-1:10.5.4+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
2020-07-15 19:21:49+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
2020-07-15 19:21:58 5 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating database wordpress
2020-07-15 19:21:58+00:00 [Note] [Entrypoint]: Creating user root
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%'
2020-07-15 19:21:59+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:22:00+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-07-15 19:22:00+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.4+maria~focal started.
2020-07-15 19:22:01 0 [Note] mysqld (mysqld 10.5.4-MariaDB-1:10.5.4+maria~focal) starting as process 1 ...
2020-07-15 19:22:01 0 [Note] mysqld: Aria engine: starting recovery
recovered pages: 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% (0.3 seconds); tables to flush: 4 3 2 1 0
(0.0 seconds);
2020-07-15 19:22:01 0 [Note] mysqld: Aria engine: recovery done
2020-07-15 19:22:01 0 [Note] InnoDB: Using Linux native AIO
2020-07-15 19:22:01 0 [Note] InnoDB: Uses event mutexes
2020-07-15 19:22:01 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-07-15 19:22:01 0 [Note] InnoDB: Number of pools: 1
2020-07-15 19:22:01 0 [Note] InnoDB: Using SSE4.2 crc32 instructions
2020-07-15 19:22:01 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-07-15 19:22:01 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2020-07-15 19:22:01 0 [Note] InnoDB: Completed initialization of buffer pool
2020-07-15 19:22:01 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-07-15 19:22:01 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=45069
2020-07-15 19:22:01 0 [Note] InnoDB: 128 rollback segments are active.
2020-07-15 19:22:01 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-07-15 19:22:01 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-07-15 19:22:01 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-07-15 19:22:02 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-07-15 19:22:02 0 [Note] InnoDB: 10.5.4 started; log sequence number 45081; transaction id 21
2020-07-15 19:22:02 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-07-15 19:22:02 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-07-15 19:22:02 0 [Note] InnoDB: Buffer pool(s) load completed at 200715 19:22:02
2020-07-15 19:22:02 0 [Note] Server socket created on IP: '::'.
2020-07-15 19:22:02 0 [Warning] 'proxies_priv' entry '#% root#5666e0d8e52e' ignored in --skip-name-resolve mode.
2020-07-15 19:22:02 0 [Note] Reading of all Master_info entries succeeded
2020-07-15 19:22:02 0 [Note] Added new Master_info '' to hash table
2020-07-15 19:22:02 0 [Note] mysqld: ready for connections.
Version: '10.5.4-MariaDB-1:10.5.4+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
[Edit]
I logged into the CLI for the db container, and verified that my init.sql script is in the docker-entrypoint-initdb.d folder:
$ cd docker-entrypoint-initdb.d
$ ls
init.sql
$ pwd
/docker-entrypoint-initdb.d
Anyone have any ideas on what else to check?
I faced an identical issue and I investigated the logs more closely.
I wasn't sure if the following error was related but I decided to get rid of it.
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%'
It seems that root user is created by default so I changed the environment variable of the user to user for example instead of root:
MYSQL_USER: user
After that I built and run the docker-compose.yml file and the SQL scripts executed succesfuly.
I had to reset the data volume otherwise the entry script would not trigger. In this case you would have to delete all contents:
sudo rm -rf /cms/conf/mysql/data/

Docker - mysql db getting installed but user not getting created

I am trying to create a hybrid container.
Following is my docker-compose file.
version: "2"
services:
database:
build:
context: ./registration-database
image: registration-database
# set default mysql root password, change as needed
environment:
MYSQL_ROOT_PASSWORD: password
# Expose port 3306 to host.
ports:
- "3306:3306"
restart: always
webserver:
build:
context: ./registration-webserver
image: registration-webserver
# mount point for application in tomcat
volumes:
- ./app/target/UserSignup:/usr/local/tomcat/webapps/UserSignup
links:
- database:registration-database
# open ports for tomcat and remote debugging
ports:
- "8080:8080"
- "8000:8000"
restart: always
Following is the dockerFile for mysql:
FROM mysql:5.7
# Copy the database initialize script:
# Contents of /docker-entrypoint-initdb.d are run on mysqld startup
ADD docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
ENV MYSQL_DATABASE=ishan
ENV MYSQL_USER=ishan
ENV MYSQL_PASSWORD=password
Following is the initialize_db.sql file
USE `ishan`;
CREATE TABLE `user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateOfBirth` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`emailAddress` varchar(255) NOT NULL,
`firstName` varchar(255) NOT NULL,
`lastName` varchar(255) NOT NULL,
`password` varchar(8) NOT NULL,
`userName` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1;
Earlier when I was running the command docker-compose up it was creating the user ishan and it was creating the user table also. But now, suddenly something happened although the mysql is getting installed with the root user but the new user (ishan) and the table is not getting created. Any help is appreciated.
Following is the log which is getting printed on startup:
Starting app_database_1 ... done
Starting app_webserver_1 ... done
Attaching to app_database_1, app_webserver_1
database_1 | 2019-04-09T08:30:51.326732Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
database_1 | 2019-04-09T08:30:51.327850Z 0 [Note] mysqld (mysqld 5.7.25) starting as process 1 ...
database_1 | 2019-04-09T08:30:51.330081Z 0 [Note] InnoDB: PUNCH HOLE support available
database_1 | 2019-04-09T08:30:51.330114Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
database_1 | 2019-04-09T08:30:51.330118Z 0 [Note] InnoDB: Uses event mutexes
database_1 | 2019-04-09T08:30:51.330121Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
database_1 | 2019-04-09T08:30:51.330125Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2019-04-09T08:30:51.330127Z 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2019-04-09T08:30:51.330295Z 0 [Note] InnoDB: Number of pools: 1
database_1 | 2019-04-09T08:30:51.330382Z 0 [Note] InnoDB: Using CPU crc32 instructions
database_1 | 2019-04-09T08:30:51.331394Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
database_1 | 2019-04-09T08:30:51.336481Z 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2019-04-09T08:30:51.338022Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
database_1 | 2019-04-09T08:30:51.356556Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
database_1 | 2019-04-09T08:30:51.372677Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2019-04-09T08:30:51.372933Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2019-04-09T08:30:51.398496Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2019-04-09T08:30:51.399884Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
database_1 | 2019-04-09T08:30:51.399990Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
database_1 | 2019-04-09T08:30:51.400792Z 0 [Note] InnoDB: 5.7.25 started; log sequence number 12359503
database_1 | 2019-04-09T08:30:51.401039Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2019-04-09T08:30:51.401382Z 0 [Note] Plugin 'FEDERATED' is disabled.
database_1 | 2019-04-09T08:30:51.419097Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
database_1 | 2019-04-09T08:30:51.421195Z 0 [Warning] CA certificate ca.pem is self signed.
database_1 | 2019-04-09T08:30:51.423199Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
database_1 | 2019-04-09T08:30:51.423332Z 0 [Note] IPv6 is available.
database_1 | 2019-04-09T08:30:51.423468Z 0 [Note] - '::' resolves to '::';
database_1 | 2019-04-09T08:30:51.423622Z 0 [Note] Server socket created on IP: '::'.
database_1 | 2019-04-09T08:30:51.430839Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
database_1 | 2019-04-09T08:30:51.434012Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190409 8:30:51
database_1 | 2019-04-09T08:30:51.437767Z 0 [Warning] 'user' entry 'root#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.437887Z 0 [Warning] 'user' entry 'mysql.session#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.438037Z 0 [Warning] 'user' entry 'mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.438612Z 0 [Warning] 'db' entry 'performance_schema mysql.session#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.438712Z 0 [Warning] 'db' entry 'sys mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.439004Z 0 [Warning] 'proxies_priv' entry '# root#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.451035Z 0 [Warning] 'tables_priv' entry 'user mysql.session#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.451161Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys#localhost' ignored in --skip-name-resolve mode.
database_1 | 2019-04-09T08:30:51.484566Z 0 [Note] Event Scheduler: Loaded 0 events
database_1 | 2019-04-09T08:30:51.485090Z 0 [Note] mysqld: ready for connections.
database_1 | Version: '5.7.25' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
Most probably your volume is still present and for that reason MySQL ignores the entrypoint folder. You need to delete the volume between runs to get a fresh start. Be aware that this means losing data saved in mysql in the meantime.
docker-compose down
# this will clean all volumes not in use by any containers
docker volume prune
Run docker volume ls to make sure your volume is gone and then run your docker-compose again.

Docker container won't start the mysql-client

My Dockerfile:
FROM mysql:5.6
ENV MYSQL_ROOT_PASSWORD=pass
ENV MYSQL_DATABASE=some_db
ENV MYSQL_USER=some_user
ENV MYSQL_PASSWORD=pass
i use this command to run a container
docker run --name mymysql --rm -it -p 3306:3306 mysql
the script start and stop here.
... some logs
MySQL init process done. Ready for start up.
2018-06-15 12:15:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-06-15 12:15:49 0 [Note] mysqld (mysqld 5.6.40) starting as process 1 ...
2018-06-15 12:15:49 1 [Note] Plugin 'FEDERATED' is disabled.
2018-06-15 12:15:49 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-06-15 12:15:49 1 [Note] InnoDB: The InnoDB memory heap is disabled
2018-06-15 12:15:49 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-06-15 12:15:49 1 [Note] InnoDB: Memory barrier is not used
2018-06-15 12:15:49 1 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-06-15 12:15:49 1 [Note] InnoDB: Using Linux native AIO
2018-06-15 12:15:49 1 [Note] InnoDB: Using CPU crc32 instructions
2018-06-15 12:15:49 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-06-15 12:15:49 1 [Note] InnoDB: Completed initialization of buffer pool
2018-06-15 12:15:49 1 [Note] InnoDB: Highest supported file format is Barracuda.
2018-06-15 12:15:49 1 [Note] InnoDB: 128 rollback segment(s) are active.
2018-06-15 12:15:49 1 [Note] InnoDB: Waiting for purge to start
2018-06-15 12:15:49 1 [Note] InnoDB: 5.6.40 started; log sequence number 1625997
2018-06-15 12:15:49 1 [Note] Server hostname (bind-address): '*'; port: 3306
2018-06-15 12:15:49 1 [Note] IPv6 is available.
2018-06-15 12:15:49 1 [Note] - '::' resolves to '::';
2018-06-15 12:15:49 1 [Note] Server socket created on IP: '::'.
2018-06-15 12:15:49 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2018-06-15 12:15:49 1 [Warning] 'proxies_priv' entry '# root#1804588a972e' ignored in --skip-name-resolve mode.
2018-06-15 12:15:49 1 [Note] Event Scheduler: Loaded 0 events
2018-06-15 12:15:49 1 [Note] mysqld: ready for connections.
Version: '5.6.40' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
....NOTHING HAPPENS
I need a command that run a container and start directly the mysql-client.

Resources