Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: mariadb needs root@"IP" to access database in container #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Edukarl
Copy link

@Edukarl Edukarl commented Feb 13, 2024

As i got access denied with your script for a Backup of paperless-mariadb i found this from https://stackoverflow.com/questions/61950105/docker-doesnt-set-mariadb-password :

MySQL user is defined by username and host that request come from. For example, there is three different user [email protected], root@localhost and wildcard root@%.

If you set MYSQL_ROOT_PASSWORD env in docker-compose file, your mariadb will set password for user root@%, not password for user root@localhost.

But when you try to test password of mariadb, you use sudo docker exec -it docker_db_1 mysql -u root -p command, it mean mariadb-client in container will use user root@local (without password) to access mariadb-server, not user root@%(that have password you set before).

So if you want to test password you set for that user, use that command:

docker run -it mariadb mysql -u root -h MARIADB-CONTAINER-IP -p

…ined here: https://stackoverflow.com/questions/61950105/docker-doesnt-set-mariadb-password

MySQL user is defined by username and host that request come from. For example, there is three different user [email protected], root@localhost and wildcard root@%.

If you set MYSQL_ROOT_PASSWORD env in docker-compose file, your mariadb will set password for user root@%, not password for user root@localhost.

But when you try to test password of mariadb, you use sudo docker exec -it docker_db_1 mysql -u root -p command, it mean mariadb-client in container will use user root@local (without password) to access mariadb-server, not user root@%(that have password you set before).

So if you want to test password you set for that user, use that command:

docker run -it mariadb mysql -u root -h MARIADB-CONTAINER-IP -p
@alaub81
Copy link
Owner

alaub81 commented Feb 18, 2024

Thank you!
I will have a look on that in a few weeks. To busy at the moment :-(

@Edukarl
Copy link
Author

Edukarl commented Feb 19, 2024

Nice, thank you!

Its not a big thing, but i needed some time to adapt your solution to my database, so i thought i'd share that!

@alaub81
Copy link
Owner

alaub81 commented Mar 18, 2024

Hi @Edukarl ,

now I got some time to check your commit.
I do not get the purpose of it. Do you have trouble with the backup? Please help me to understand, why you like to use root@%

On my setups, the mariadb and mysql Passwort of root@localhost is set up correctly. But perhaps it is because the setup is running for years now and they changed the up the setup process, when you are running a clean mysql or mariadb container.

Thank you!

cheers
Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants