Galera Mysql wsrep_cluster_status stays Disconnected - mysql

My cluster was previously running, I have made these config changes and now Galera cluster bootstrap is not working.
I tried bootstraping with /usr/bin/mysqld_bootstrap as well as service mysql start --wsrep-new-cluster . but no luck.
mysql> SHOW GLOBAL STATUS WHERE Variable_name IN ('wsrep_ready', 'wsrep_cluster_size', 'wsrep_cluster_status', 'wsrep_connected');
+----------------------+--------------+
| Variable_name | Value |
+----------------------+--------------+
| wsrep_cluster_size | 0 |
| wsrep_cluster_status | Disconnected |
| wsrep_connected | OFF |
| wsrep_ready | ON |
+----------------------+--------------+
4 rows in set (0.00 sec)
root#hostname:/var/lib/mysql# cat /etc/my.cnf
[mysqld]
# character set
character_set_server = utf8
collation_server = utf8_general_ci
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
binlog_format=ROW
# Galera Cluster Configuration
wsrep_node_address="ip"
wsrep_node_name="hostname"
wsrep_cluster_name="mysql_cluster"
wsrep_cluster_address="gcomm://"
wsrep_provider_options = "gcache.size = 16G; gcache.recover = yes; gmcast.segment=0; gmcast.time_wait=PT5S; cert.log_conflicts=ON;"
wsrep_retry_autocommit=5
wsrep_slave_threads=64
wsrep_log_conflicts=ON
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_sst_method=rsync # Galera Synchronization Configuration
# wsrep_certify_nonPK=1 # make sure primary key is present in a DB
# Mysql configurations
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=2
innodb_buffer_pool_size=20G # 80% of total memory
table_open_cache=8192
max_connections=500
innodb_buffer_pool_instances=40
thread_cache_size=128
max_allowed_packet=16M
thread_stack=192K
[mysql_safe]
log-error=/var/log/mysql/error.log
pid-file=/var/run/mysqld/mysqld.pid
#include mysql config
!includedir /etc/mysql/conf.d/
error.log
2020-05-10T14:52:11.510387Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-10T14:52:11.512408Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-log) starting as process 38762 ...
2020-05-10T14:52:11.516208Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-05-10T14:52:11.516233Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-10T14:52:11.516240Z 0 [Note] InnoDB: Uses event mutexes
2020-05-10T14:52:11.516246Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-05-10T14:52:11.516251Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-10T14:52:11.516259Z 0 [Note] InnoDB: Using Linux native AIO
2020-05-10T14:52:11.516566Z 0 [Note] InnoDB: Number of pools: 1
2020-05-10T14:52:11.516689Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-05-10T14:52:11.518701Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-05-10T14:52:11.528085Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-05-10T14:52:11.530536Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-05-10T14:52:11.542537Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-05-10T14:52:11.559072Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-05-10T14:52:11.559138Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-05-10T14:52:11.601120Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-05-10T14:52:11.602357Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-05-10T14:52:11.602377Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-05-10T14:52:11.602854Z 0 [Note] InnoDB: Waiting for purge to start
2020-05-10T14:52:11.653077Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 3779657135
2020-05-10T14:52:11.653388Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-05-10T14:52:11.653670Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-05-10T14:52:11.656614Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200510 7:52:11
2020-05-10T14:52:11.665175Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-05-10T14:52:11.665203Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-05-10T14:52:11.666274Z 0 [Warning] CA certificate ca.pem is self signed.
2020-05-10T14:52:11.666344Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-05-10T14:52:11.667341Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-05-10T14:52:11.667427Z 0 [Note] IPv6 is available.
2020-05-10T14:52:11.667444Z 0 [Note] - '::' resolves to '::';
2020-05-10T14:52:11.667487Z 0 [Note] Server socket created on IP: '::'.
2020-05-10T14:52:11.686718Z 0 [Note] Event Scheduler: Loaded 0 events
2020-05-10T14:52:11.686771Z 0 [Note] WSREP: Initial position: 00000000-0000-0000-b0f1-bf0300000000:62901600
2020-05-10T14:52:11.686784Z 0 [Warning] WSREP: Initial position was provided by configuration or SST, avoiding override
2020-05-10T14:52:11.686792Z 0 [Note] WSREP: wsrep_load(): loading provider library 'none'
2020-05-10T14:52:11.687082Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.29-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Wsrep Server (GPL), wsrep_25.21
2020-05-10T14:52:12.732431Z 2 [Note] Access denied for user 'root'#'localhost' (using password: NO)
2020-05-10T14:57:11.957879Z 4 [Note] WSREP: Stop replication
2020-05-10T14:57:11.957918Z 4 [Note] Giving 1 client threads a chance to die gracefully

Make sure it belongs to mysql user and mysql group
chown mysql:mysql /etc/my.cnf
Also, and very important, make sure the library is in /etc/my.cnf
symbolic-links=0
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

The file /etc/my.cnf was missing read permissions. This file requires read permission for mysql user. I have set the permission to 755 and Galera configuration was loaded properly.
chmod 775 /etc/my.cnf

Related

MySQL docker: Import schema file with error: inet addr:'| cut -d: -f2 | awk '{ print $1}'", "commandName": "IP"}], "clamAvInt'

I am working with MySQL docker image version 5.7 with initialize the data by the schema file but got some error can't solve.
My docker command line is:
docker run --name mysql -e MYSQL_ROOT_PASSWORD='abc123' -v /Users/jenkins/Desktop/irms:/docker-entrypoint-initdb.d mysql:5.7
and get the error, the log as below:
$ docker run --name mysql -e MYSQL_ROOT_PASSWORD='abc123' -v /Users/jenkins/Desktop/irms:/docker-entrypoint-initdb.d mysql:5.7
2021-03-17 02:05:15+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-03-17 02:05:15+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-03-17 02:05:15+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-03-17 02:05:15+00:00 [Note] [Entrypoint]: Initializing database files
2021-03-17T02:05:15.606058Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-03-17T02:05:15.756090Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-03-17T02:05:15.779384Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-03-17T02:05:15.837663Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 373d4ffb-86c5-11eb-8780-0242ac110002.
2021-03-17T02:05:15.839186Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-03-17T02:05:16.450734Z 0 [Warning] CA certificate ca.pem is self signed.
2021-03-17T02:05:16.576740Z 1 [Warning] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2021-03-17 02:05:18+00:00 [Note] [Entrypoint]: Database files initialized
2021-03-17 02:05:18+00:00 [Note] [Entrypoint]: Starting temporary server
2021-03-17 02:05:18+00:00 [Note] [Entrypoint]: Waiting for server startup
2021-03-17T02:05:18.819727Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-03-17T02:05:18.820623Z 0 [Note] mysqld (mysqld 5.7.33) starting as process 78 ...
2021-03-17T02:05:18.822725Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-03-17T02:05:18.822772Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-03-17T02:05:18.822783Z 0 [Note] InnoDB: Uses event mutexes
2021-03-17T02:05:18.822789Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2021-03-17T02:05:18.822795Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-03-17T02:05:18.822800Z 0 [Note] InnoDB: Using Linux native AIO
2021-03-17T02:05:18.823072Z 0 [Note] InnoDB: Number of pools: 1
2021-03-17T02:05:18.823301Z 0 [Note] InnoDB: Using CPU crc32 instructions
2021-03-17T02:05:18.824551Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-03-17T02:05:18.829149Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-03-17T02:05:18.830692Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-03-17T02:05:18.841912Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2021-03-17T02:05:18.846985Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-03-17T02:05:18.847098Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-03-17T02:05:18.862891Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-03-17T02:05:18.863475Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2021-03-17T02:05:18.863521Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2021-03-17T02:05:18.863960Z 0 [Note] InnoDB: Waiting for purge to start
2021-03-17T02:05:18.914486Z 0 [Note] InnoDB: 5.7.33 started; log sequence number 2746831
2021-03-17T02:05:18.915203Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2021-03-17T02:05:18.915523Z 0 [Note] Plugin 'FEDERATED' is disabled.
2021-03-17T02:05:18.916967Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210317 2:05:18
2021-03-17T02:05:18.920098Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2021-03-17T02:05:18.920168Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2021-03-17T02:05:18.920570Z 0 [Warning] CA certificate ca.pem is self signed.
2021-03-17T02:05:18.920635Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2021-03-17T02:05:18.922497Z 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.
2021-03-17T02:05:18.926990Z 0 [Note] Event Scheduler: Loaded 0 events
2021-03-17T02:05:18.927219Z 0 [Note] mysqld: ready for connections.
Version: '5.7.33' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL)
2021-03-17 02:05:19+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2021-03-17 02:05:20+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/IRMSDB_2021-03-09.sql
ERROR 1064 (42000) at line 287: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'inet addr:'| cut -d: -f2 | awk '{ print $1}'", "commandName": "IP"}], "clamAvInt' at line 5
I checked my schema file and no idea what the error exactly and no idea how to fix it.
My schema file is exported from Sequel Pro.
Could you kindly provide some idea to solve the problem?
Thanks very much.
Just attached my schema file below, and please change the extension name from jpg to SQL.
Click here to download: MySQL schema file

How to access db [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'172.18.0.3' (using password: YES)] in docker container

I have the following docker-compose.yml file.
I would like to buildthem and connect to DB
version: '3'
services:
api-server:
build: ./api
links:
- 'db'
ports:
- '3000:3000'
volumes:
- ./api:/src
- ./src/node_modules
tty: true
container_name: api-server
db:
build:
context: .
dockerfile: ./db/Dockerfile
restart: always
hostname: db
environment:
MYSQL_ROOT_PASSWORD: test
MYSQL_USER: root
MYSQL_PASSWORD: test
MYSQL_DATABASE: db
volumes:
- './db:/config'
ports:
- 3306:3306
container_name: db
After docker-compose build
then docker-compose up -d
And then `docker exec -it api-server sh'
I could enter containers. and tried
yarn ts-node node_modules/.bin/typeorm migration:show
typeorm command which connect to DB
But it returned
Error during migration show: Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'172.18.0.3' (using password: YES)
Are there any way to fix it?
Where is the wrong point of it ?
Thanks
Here is docker logs db
docker logs db
2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
2020-09-15 11:57:44+00:00 [Note] [Entrypoint]: Initializing database files
2020-09-15T11:57:44.868762Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-09-15T11:57:46.939481Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-09-15T11:57:47.252278Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-09-15T11:57:47.327831Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: abfbf3cb-f74a-11ea-bfe8-0242ac120002.
2020-09-15T11:57:47.331570Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-09-15T11:57:48.443477Z 0 [Warning] CA certificate ca.pem is self signed.
2020-09-15T11:57:48.733702Z 1 [Warning] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2020-09-15 11:57:52+00:00 [Note] [Entrypoint]: Database files initialized
2020-09-15 11:57:52+00:00 [Note] [Entrypoint]: Starting temporary server
2020-09-15 11:57:52+00:00 [Note] [Entrypoint]: Waiting for server startup
2020-09-15T11:57:52.490209Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-09-15T11:57:52.492212Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 77 ...
2020-09-15T11:57:52.497001Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-09-15T11:57:52.497114Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-09-15T11:57:52.497223Z 0 [Note] InnoDB: Uses event mutexes
2020-09-15T11:57:52.497332Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-09-15T11:57:52.497452Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-09-15T11:57:52.497542Z 0 [Note] InnoDB: Using Linux native AIO
2020-09-15T11:57:52.498106Z 0 [Note] InnoDB: Number of pools: 1
2020-09-15T11:57:52.498434Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-09-15T11:57:52.501015Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-09-15T11:57:52.515593Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-09-15T11:57:52.518852Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-09-15T11:57:52.531163Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-09-15T11:57:52.555422Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-09-15T11:57:52.555698Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-09-15T11:57:52.665854Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-09-15T11:57:52.667159Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-09-15T11:57:52.667286Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-09-15T11:57:52.668320Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 2720554
2020-09-15T11:57:52.669761Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-09-15T11:57:52.669911Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-09-15T11:57:52.672485Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200915 11:57:52
2020-09-15T11:57:52.683725Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-09-15T11:57:52.683951Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-09-15T11:57:52.684864Z 0 [Warning] CA certificate ca.pem is self signed.
2020-09-15T11:57:52.684970Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-09-15T11:57:52.687815Z 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.
2020-09-15T11:57:52.704435Z 0 [Note] Event Scheduler: Loaded 0 events
2020-09-15T11:57:52.705512Z 0 [Note] mysqld: ready for connections.
Version: '5.7.31' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL)
2020-09-15 11:57:53+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2020-09-15 11:58:00+00:00 [Note] [Entrypoint]: Creating database mogucare_db
2020-09-15 11:58:00+00:00 [Note] [Entrypoint]: Creating user root
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'#'%'
2020-09-15 11:58:02+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
2020-09-15 11:58:03+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-09-15 11:58:03+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
2020-09-15T11:58:03.406842Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-09-15T11:58:03.409690Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 1 ...
2020-09-15T11:58:03.418038Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-09-15T11:58:03.418101Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-09-15T11:58:03.418117Z 0 [Note] InnoDB: Uses event mutexes
2020-09-15T11:58:03.418133Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-09-15T11:58:03.418152Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-09-15T11:58:03.418170Z 0 [Note] InnoDB: Using Linux native AIO
2020-09-15T11:58:03.419647Z 0 [Note] InnoDB: Number of pools: 1
2020-09-15T11:58:03.420784Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-09-15T11:58:03.425652Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-09-15T11:58:03.448462Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-09-15T11:58:03.457474Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-09-15T11:58:03.473399Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-09-15T11:58:03.477057Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 2720554
2020-09-15T11:58:03.737975Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 7963136
2020-09-15T11:58:03.934900Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12578409
2020-09-15T11:58:03.936536Z 0 [Note] InnoDB: Database was not shutdown normally!
2020-09-15T11:58:03.936685Z 0 [Note] InnoDB: Starting crash recovery.
2020-09-15T11:58:04.147681Z 0 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
2020-09-15T11:58:05.179148Z 0 [Note] InnoDB: Apply batch completed
2020-09-15T11:58:05.286743Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-09-15T11:58:05.286809Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-09-15T11:58:05.286925Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-09-15T11:58:05.374586Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-09-15T11:58:05.376546Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-09-15T11:58:05.377004Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-09-15T11:58:05.378022Z 0 [Note] InnoDB: Waiting for purge to start
2020-09-15T11:58:05.439607Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 12578409
2020-09-15T11:58:05.442005Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-09-15T11:58:05.454028Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-09-15T11:58:05.492756Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200915 11:58:05
2020-09-15T11:58:05.518753Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-09-15T11:58:05.518785Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-09-15T11:58:05.519497Z 0 [Warning] CA certificate ca.pem is self signed.
2020-09-15T11:58:05.519541Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-09-15T11:58:05.536601Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-09-15T11:58:05.537666Z 0 [Note] IPv6 is available.
2020-09-15T11:58:05.537947Z 0 [Note] - '::' resolves to '::';
2020-09-15T11:58:05.538239Z 0 [Note] Server socket created on IP: '::'.
2020-09-15T11:58:05.552491Z 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.
2020-09-15T11:58:05.574297Z 0 [Note] Event Scheduler: Loaded 0 events
2020-09-15T11:58:05.574997Z 0 [Note] mysqld: ready for connections.
Version: '5.7.31' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
2020-09-15T11:59:47.472547Z 3 [Note] Access denied for user 'root'#'172.18.0.3' (using password: YES)
2020-09-15T12:03:15.760923Z 4 [Note] Access denied for user 'root'#'172.18.0.3' (using password: YES)
The reason is in MySQL database mysql, table users. The user you are connecting with doesn't have permission - either because it doesn't exist, you have the wrong password, or you have no rights to connect from your IP to the target database.
In many cases, MySQL docker containers come configured to only allow connections to localhost (127.0.0.1) which means you must either (a) use port forwarding or (b) grant the user permission to connect from anywhere (i.e. %). Sometimes there is also a configuration switch that will automatically do this for you - read the documentation for your db container.

MAMP SQLSTATE[HY000] [2006] MySQL server has gone away on Mac Catalina

I googled and the solution was to add/edit this:
[mysqld]
wait_timeout=100000
max_allowed_packet = 256M
into this file /etc/mysql/my.cnf and but i cant find etc, where is the etc?
mysql_error_log.err
2020-02-26T13:09:54.6NZ mysqld_safe Logging to
'/Applications/MAMP/logs/mysql_error_log.err'. 2020-02-26T13:09:54.6NZ
mysqld_safe Starting mysqld daemon with databases from
/Applications/MAMP/db/mysql57 2020-02-26T13:09:54.943202Z 0 [Warning]
TIMESTAMP with implicit DEFAULT value is deprecated. Please use
--explicit_defaults_for_timestamp server option (see documentation for more details). 2020-02-26T13:09:54.943551Z 0 [Note] --secure-file-priv
is set to NULL. Operations related to importing and exporting data are
disabled 2020-02-26T13:09:54.943611Z 0 [Note]
/Applications/MAMP/Library/bin/mysqld (mysqld 5.7.26) starting as
process 2189 ... 2020-02-26T13:09:54.949688Z 0 [Warning] Setting
lower_case_table_names=2 because file system for
/Applications/MAMP/db/mysql57/ is case insensitive
2020-02-26T13:09:54.952118Z 0 [Note] InnoDB: Mutexes and rw_locks use
GCC atomic builtins 2020-02-26T13:09:54.952159Z 0 [Note] InnoDB: Uses
event mutexes 2020-02-26T13:09:54.952176Z 0 [Note] InnoDB: GCC builtin
__atomic_thread_fence() is used for memory barrier 2020-02-26T13:09:54.952187Z 0 [Note] InnoDB: Compressed tables use
zlib 1.2.11 2020-02-26T13:09:54.952681Z 0 [Note] InnoDB: Number of
pools: 1 2020-02-26T13:09:54.952894Z 0 [Note] InnoDB: Using CPU crc32
instructions 2020-02-26T13:09:54.955089Z 0 [Note] InnoDB: Initializing
buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-02-26T13:09:54.971785Z 0 [Note] InnoDB: Completed initialization
of buffer pool 2020-02-26T13:09:54.990800Z 0 [Note] InnoDB: Highest
supported file format is Barracuda. 2020-02-26T13:09:55.005564Z 0
[Note] InnoDB: Creating shared tablespace for temporary tables
2020-02-26T13:09:55.005739Z 0 [Note] InnoDB: Setting file './ibtmp1'
size to 12 MB. Physically writing the file full; Please wait ...
2020-02-26T13:09:55.024819Z 0 [Note] InnoDB: File './ibtmp1' size is
now 12 MB. 2020-02-26T13:09:55.025655Z 0 [Note] InnoDB: 96 redo
rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-02-26T13:09:55.025678Z 0 [Note] InnoDB: 32 non-redo rollback
segment(s) are active. 2020-02-26T13:09:55.025883Z 0 [Note] InnoDB:
Waiting for purge to start 2020-02-26T13:09:55.079934Z 0 [Note]
InnoDB: 5.7.26 started; log sequence number 2551871
2020-02-26T13:09:55.080171Z 0 [Note] InnoDB: Loading buffer pool(s)
from /Applications/MAMP/db/mysql57/ib_buffer_pool
2020-02-26T13:09:55.080257Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-02-26T13:09:55.086927Z 0 [Warning] InnoDB: Table
mysql/innodb_table_stats has length mismatch in the column name
table_name. Please run mysql_upgrade 2020-02-26T13:09:55.086990Z 0
[Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch
in the column name table_name. Please run mysql_upgrade
2020-02-26T13:09:55.090242Z 0 [Warning] Failed to set up SSL because
of the following SSL library error: SSL context is not usable without
certificate and private key 2020-02-26T13:09:55.090273Z 0 [Note]
Server hostname (bind-address): '*'; port: 3306
2020-02-26T13:09:55.090660Z 0 [Note] IPv6 is available.
2020-02-26T13:09:55.090721Z 0 [Note] - '::' resolves to '::';
2020-02-26T13:09:55.090868Z 0 [Note] Server socket created on IP:
'::'. 2020-02-26T13:09:55.093848Z 0 [Note] InnoDB: Buffer pool(s) load
completed at 200226 21:09:55 2020-02-26T13:09:55.173772Z 0 [Note]
Event Scheduler: Loaded 0 events 2020-02-26T13:09:55.173947Z 0 [Note]
/Applications/MAMP/Library/bin/mysqld: ready for connections. Version:
'5.7.26' socket: '/Applications/MAMP/tmp/mysql/mysql.sock' port:
3306 MySQL Community Server (GPL) 2020-02-26T13:10:18.977842Z 2
[Note] Got an error reading communication packets
You're using MAMP so you will need to create a new file in /Applications/MAMP/conf/ called my.conf
Your full file path will be /Applications/MAMP/conf/my.conf and the contents will be:
[mysqld]
wait_timeout=100000
max_allowed_packet = 256M
Once you've added the file you probably need to restart your mysql server in MAMP

MySql startup error ' ERROR! The server quit without updating PID file'

I have tried every link that is on S.O but still getting the same outcome every time I try to start MySQL. Following is the log from the .err file.
2018-01-07T06:58:11.729500Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-01-07T06:58:11.731659Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-01-07T06:58:11.731673Z 0 [Note] InnoDB: Uses event mutexes
2018-01-07T06:58:11.731679Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-01-07T06:58:11.731682Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-01-07T06:58:11.731969Z 0 [Note] InnoDB: Number of pools: 1
2018-01-07T06:58:11.732068Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-01-07T06:58:11.733672Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-01-07T06:58:11.745339Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-01-07T06:58:11.761905Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-01-07T06:58:11.906535Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-01-07T06:58:11.906692Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-01-07T06:58:11.918639Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-01-07T06:58:11.919925Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-01-07T06:58:11.919938Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-01-07T06:58:11.920116Z 0 [Note] InnoDB: Waiting for purge to start
2018-01-07T06:58:11.974340Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 129183358
2018-01-07T06:58:11.974571Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2018-01-07T06:58:11.974744Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-01-07T06:58:11.974853Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180107 12:28:11
2018-01-07T06:58:11.983233Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-01-07T06:58:11.983254Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2018-01-07T06:58:11.983981Z 0 [Warning] CA certificate ca.pem is self signed.
2018-01-07T06:58:11.984032Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2018-01-07T06:58:11.989041Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-01-07T06:58:11.989070Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2018-01-07T06:58:11.989136Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-01-07T06:58:11.989166Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
2018-01-07T06:58:11.989169Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2018-01-07T06:58:11.989199Z 0 [ERROR] Aborting
It looks like you have some other software that is using the port 3306. MySQL uses this port, but it's failing to bind to it because it is in use. End the other software and try to launch MySQL again.
If you need to have the other software running at the same time with MySQL, you have to change the default port in one of them to some other unused port.
To change the port in MySQL. If you're on Windows, find the my.ini file for MySQL installation, open this file in a text editor and look for this section:
# The TCP/IP Port the MySQL Server will listen on
port=3306
Then change the number of the port, save the file, and restart the MySQL service.

MySQL won't start on Linux

I have a fresh mysql-server install (installed via yum) that will not start
bash-4.1# /sbin/service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
The /etc/my.cnf has been set to default:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
The error I receive is:
2016-02-16T22:47:18.453320Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2016-02-16T22:47:18.888497Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-16T22:47:18.889955Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.11) starting as process 4321 ...
2016-02-16T22:47:19.016515Z 0 [Note] InnoDB: PUNCH HOLE support available
2016-02-16T22:47:19.016568Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-16T22:47:19.016583Z 0 [Note] InnoDB: Uses event mutexes
2016-02-16T22:47:19.016596Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2016-02-16T22:47:19.016609Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-02-16T22:47:19.016631Z 0 [Note] InnoDB: Using Linux native AIO
2016-02-16T22:47:19.018127Z 0 [Note] InnoDB: Number of pools: 1
2016-02-16T22:47:19.018819Z 0 [Note] InnoDB: Using CPU crc32 instructions
2016-02-16T22:47:19.052517Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2016-02-16T22:47:19.071855Z 0 [Note] InnoDB: Completed initialization of buffer pool
2016-02-16T22:47:19.078235Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2016-02-16T22:47:19.092945Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2016-02-16T22:47:19.107542Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2016-02-16T22:47:19.107588Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2016-02-16T22:47:19.160738Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2016-02-16T22:47:19.163712Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2016-02-16T22:47:19.163748Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2016-02-16T22:47:19.165210Z 0 [Note] InnoDB: Waiting for purge to start
2016-02-16T22:47:19.215586Z 0 [Note] InnoDB: 5.7.11 started; log sequence number 1210437
2016-02-16T22:47:19.216328Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2016-02-16T22:47:19.217459Z 0 [Note] Plugin 'FEDERATED' is disabled.
2016-02-16T22:47:19.217537Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160216 22:47:19
mysqld: Table 'mysql.plugin' doesn't exist
2016-02-16T22:47:19.217905Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-02-16T22:47:19.219399Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-02-16T22:47:19.219650Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2016-02-16T22:47:19.220055Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-02-16T22:47:19.220231Z 0 [Note] IPv6 is available.
2016-02-16T22:47:19.220261Z 0 [Note] - '::' resolves to '::';
2016-02-16T22:47:19.220280Z 0 [Note] Server socket created on IP: '::'.
2016-02-16T22:47:19.233206Z 0 [Warning] Failed to open optimizer cost constant tables
2016-02-16T22:47:19.233439Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2016-02-16T22:47:19.233551Z 0 [ERROR] Aborting
However, I can't run mysql_upgrade as mysqld isn't running. Other sites have stated that file permissions of the data files could be an issue, but they are all owned by mysql (i.e. I believe correct). I've also tried running mysqld_safe, but without success.
Can someone please suggest what I've done wrong?
Thanks Mark.
mysql_install_db didn't work (was deprecated, and then the suggested initialise failed). However, a complete clean and reinstall resolved the issue.
For reference, the exact steps I performed were:
yum remove mysql
rm -fr /usr/bin/mysql
rm -fr /var/lib/mysql
rm -fr /etc/my*
(reboot)
yum install mysql-community-{server,client,common,libs}-*
/sbin/service mysqld start