I have browsed all of the available threads regarding this issue but none of them seem to help solving my problem.
Having pulled my mariadb image with command (on root account using su):
docker pull mariadb:latest
Then running:
docker run -d --name some_name -e MYSQL_ROOT_PASSWORD=some_secret_password -p 1111:3306 -v /volume/path:/volume/path mariadb:latest
Then doing (after this command i get root@some_numbers in prompt so i assume im in root mode):
docker exec -it some_name bash
Then changing in 50-server.cnf
following line:
bind_address 172.0.0.1
-> bind_address 0.0.0.0
to supposedly accept all traffic not only from localhost
Then trying to login for the first time:
mariadb -P 1111 --protocol=tcp -u root -p
yes, i know about -p to write password like this -pPASSWORD etc. it does not work, also when leaving empty it does not work, not any variant of this command works, all of the proper ones give one, and same result:
ERROR 1045 (28000): Access denied for user 'root'@'some_ip' (using password: YES)
And i have tried it from docker container with root privileges (su mode on), on host machine with root privileges and on remote machine with root privileges all with the same result shown above. I also am aware of this one: link and I am surprised that when being literaly on root account with su mode on I still can not log in.
I also can not do anything to mariadb service to shut it down and restart with skip grant flag as shown here: link
To summarize, I want to get an access to mariadb instance that sits in container on remote server based on ubuntu to access it with another remote machine in the future, but for now after following every step I could find, I am stuck at a simple log in for the first time into database.
2
Answers
I’ve tried your example with both a mariadb 10.5 and 11.6 client and both connect using your described execution.
e.g:
The issue is
MYSQL_ROOT_PASSWORD=some_secret_password
or more modernlyMARIADB_ROOT_PASSWORD=some_secret_password
is not used after the data volume/volume/path
is initialized. Whatever the password was when the volume was created its not currentlysome_secret_password
(or whatever it really was).It also might be the case that if your
some_secret_password
contains characters with shell meanings then those may change what is passed though to the MariaDB server. Quote if unsure like'-psome_secret_password'
. For a long time the MariaDB container has been able to handle any password.If you are still stuck, reset the password with:
Please do not make any modifications. Just use the default values and it will work fine.
Host 1 – 192.168.56.107
Run Command:
Please do not make any modifications. Just use the default values and it will work fine.
Host 2 – 192.168.56.1
Run command
Result 1
input SQL Command:
SHOW GRANTS FOR 'root'@'%';
Result 2
input SQL Command:
Result 3
I didn’t make any modifications and I was able to connect to the Docker Container on host1 from the other host (host2).
Java Connection Test – From Host 2 (192.168.56.1)
JDBC URL:
jdbc:mariadb://192.168.56.107:1111/
User name:
root
Password:
yourPassword
SQL1:
SQL2:
Using the defaults, without modification, you can connect from other hosts using the
root
account. I don’t know what your real problem is? I mean everything is working fine.