MariaDB / mariadb-docker

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

latest tag 1:11.0.2+maria~ubu2204 - mysql command is gone #512

Closed stanthewizzard closed 1 year ago

stanthewizzard commented 1 year ago

Hello

mysql command is not working in latest iteration of mariadb. Is this on purpose ?

Thanks

thaJeztah commented 1 year ago

Looks on purpose; see the release notes for 11.0; https://mariadb.com/kb/en/mariadb-11-0-1-release-notes/#docker-official-images

iamromandev commented 1 year ago

Yes its surprising though. I have been forced to use previous version.

stanthewizzard commented 1 year ago

So I need to rewrite a lot of things. But whyyy ? Lol Thanks

thaJeztah commented 1 year ago

Don't know the details, but I see there's links to some tickets (my hunch would be that they may no longer be fully compatible with the mysql command line in future);

Last one mentions;

There's too many old and new people referring to MariaDB as MySQL. We need to encourage the transition in naming. Because mariadb names have began in 10.4, lets step up the conversion process by adding a deprecation notice on mysql names.

:warning: Note that 11.0 is a non-LTS release (and release notes call out to not use those in production); 10.0 is an LTS release (supported until 2028), so if you need stability, it may be preferable to use an LTS release.

iangilfillan commented 1 year ago

warning Note that 11.0 is a non-LTS release (and release notes call out to not use those in production); 10.0 is an LTS release (supported until 2028), so if you need stability, it may be preferable to use an LTS release.

To clarify, 10.0 is long EOL. The latest LTS release is 10.11: https://mariadb.org/about/#maintenance-policy

thaJeztah commented 1 year ago

Ah, you're right; thanks for correcting; I'm not too familiar with the versioning scheme used ☺️

grooverdan commented 1 year ago

For everyone using mysqladmin (or mariadb-admin) ping as a healthcheck, this is a flawed implementation. This is because the mariadb-install-db script, /docker-entrypoint-initdb.d scripts and the MARIADB_AUTO_UPGRADE=1 will start the mariadbd in a --skip-networking form to which the ping will return true (unix socket connection is the default) before shutting down after completion of that stage to auto-start again without --skip-networking.

The workaround is:

env:
      MARIADB_MYSQL_LOCALHOST_USER: 1
      MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3

This unfortunately is a little noisy without an empty root password. I started to work on a solution #508 but stalled. I'm considering a random root password for root@::1 / root@127.0.0.1 with it stored in a file passed in the healthcheck.sh --connect. Thoughts welcome.

grooverdan commented 1 year ago

wrote https://mariadb.com/kb/en/using-healthcheck-sh-script/ finally

and https://mariadb.org/mariadb-server-docker-official-images-healthcheck-without-mysqladmin/

thaJeztah commented 1 year ago

@grooverdan (haven't looked closely as my comments were basically just a drive-by 🙈) were you planning to update your https://github.com/MariaDB/mariadb-docker/pull/508 PR to update https://github.com/MariaDB/mariadb-docker/blob/master/healthcheck.sh ?

grooverdan commented 1 year ago

@grooverdan (haven't looked closely as my comments were basically just a drive-by see_no_evil)

That managed to find the release notes and the server JIRA entries :smile: .

were you planning to update your #508 PR to update https://github.com/MariaDB/mariadb-docker/blob/master/healthcheck.sh ?

Updated now. drive-by reviews welcome too :smile_cat: .

grooverdan commented 1 year ago

So healthcheck updates from #508 have been released. There is now a healthcheck@{localhost,127.0.0.1,::1} user created always with a random password, USAGE privs, and put into the /var/lib/mysql/.my-healthcheck.cnf file. If you need more MARIADB_HEALTHCHECK_GRANTS=REPLICA MONITOR for example can be set for replication based healthchecks.

As such you'll need just the following for a healthcheck without being dependent on any environment variables

options: --health-cmd="healthcheck.sh --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3

Even the --innodb_initialized occurs over TCP so doubles the same as ---connect.

I haven't see a major case for re-adding mysql commands, we where going to do it eventually, maybe a depreciation would have been nicer, but it seems to be done and the major use case of healthchecks has been improved.

Sorry for the interruption and I hope you're happy with the improved healthcheck.

gremo commented 1 year ago

Thank you @grooverdan this was really needed! For Docker users, now you can do the following:

version: '3.8'

services:
    db:
        image: mariadb:10.6
        volumes:
            - db_data:/var/lib/mysql
        environment:
            MARIADB_ROOT_PASSWORD: foo
        ports:
            - '3306:3306'
        healthcheck:
            test: ['CMD', '/usr/local/bin/healthcheck.sh', '--innodb_initialized']
            start_period: 5s
            timeout: 5s
            interval: 5s
            retries: 5

volumes:
    db_data:
stanthewizzard commented 1 year ago

@gremo tried it but access denied for root.

grooverdan commented 1 year ago

@stanthewizzard the new healthcheck user is only added for fresh installs of the data.

stanthewizzard commented 1 year ago

ok I have to add it manually. With a password ? or something else ? thanks

grooverdan commented 1 year ago

You can, like the script, create user ..., grant usage ... and create .my-healthcheck.cnf in /var/lib/mysql.

stanthewizzard commented 1 year ago

cool I'll do that

stanthewizzard commented 1 year ago

just to help other

create user in DB:

CREATE USER healthcheck@'127.0.0.1' IDENTIFIED BY '$healthCheckConnectPassEscaped';
CREATE USER healthcheck@'::1' IDENTIFIED BY '$healthCheckConnectPassEscaped';
CREATE USER healthcheck@localhost IDENTIFIED BY '$healthCheckConnectPassEscaped';

then (as there is a jonction for DB in docker compose and for ex:

volumes:
      - ./db:/var/lib/mysql

vi .my-healthcheck.cnf

[mariadb-client]
user=healthcheck
protocol=tcp

protocol=tcp needed to enforce what used to be a --connect test.

then docker exec -it watehvermariadb /bin/bash ./usr/local/bin/healthcheck.sh --innodb_initialized

NO ERROR than possible to use in docker compose

        healthcheck:
            test: ['CMD', '/usr/local/bin/healthcheck.sh', '--innodb_initialized']
            start_period: 5s
            timeout: 5s
            interval: 5s
            retries: 5