MariaDB / mariadb-docker

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

Database user not granted to % after creation #446

Closed di-rect closed 2 years ago

di-rect commented 2 years ago

When deploying a MariaDB container it seems my user is created but it's not granted using the following lines:

https://github.com/MariaDB/mariadb-docker/blob/766eea4c9c10f5915278d04f30147031567b1fd8/10.9/docker-entrypoint.sh#L360-L361

Stange things is that I see the first line mysql_note "Giving user ${MARIADB_USER} access to schema ${MARIADB_DATABASE}" being printed.

What do I need to check ?

grooverdan commented 2 years ago

Which container version are you using. What values are you using for MARIADB_DATABASE and MARIADB_USER?

If you docker exec -ti {containername} mysql -u root -p{rootpass} -e 'show grants for {mariadb_user} what does it show?

grooverdan commented 2 years ago
$ podman run --env MARIADB_ROOT_PASSWORD=a --env MARIADB_DATABASE=b --env MARIADB_USER=c --env MARIADB_PASSWORD=d --rm --name m109 mariadb:10.9-rc
...
2022-07-18 00:21:54+00:00 [Note] [Entrypoint]: Securing system users (equivalent to running mysql_secure_installation)
2022-07-18 00:21:54+00:00 [Note] [Entrypoint]: Creating database b
2022-07-18 00:21:54+00:00 [Note] [Entrypoint]: Creating user c
2022-07-18 00:21:54+00:00 [Note] [Entrypoint]: Giving user c access to schema b

2022-07-18 00:21:54+00:00 [Note] [Entrypoint]: Stopping temporary server
$ podman exec m109 mariadb -u c -pd -e 'show grants'
Grants for c@%
GRANT USAGE ON *.* TO `c`@`%` IDENTIFIED BY PASSWORD '*84869AED8A7235127BFD0AD4A55E335B29ADE3AD'
GRANT ALL PRIVILEGES ON `b`.* TO `c`@`%`

Grants are only given to the ${MARIADB_DATABASE}, so it looks like its working as intended.