Maria db docker passWordCharacterEncoding issue

Viewed 194

I've been using an app which connects to an old version of MariaDb (5.5.64) and I want to lift the db off the dev machine and into a docker image.

I have done this and all seems fine

docker pull mariadb:5.5.64
docker run --name container -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pword -d mariadb:5.5.64
docker exec -it container /bin/sh

I've gone in and created a user with outrageous permissions

CREATE USER ‘dbusr’@‘localhost’ IDENTIFIED BY ‘pword’;
GRANT ALL PRIVILEGES ON *.* TO ‘dbusr’@‘localhost’ WITH GRANT OPTION;
CREATE USER ‘dbusr’@‘%’ IDENTIFIED BY ‘pword’;
GRANT ALL PRIVILEGES ON *.* TO ‘dbusr’@‘%’ WITH GRANT OPTION;
FLUSH PRIVILEGES;

from my dev machine I can connect to the db's using this user and password. So all seems well.

When I use my application though I get

[exec] Caused by: java.sql.SQLInvalidAuthorizationSpecException: Access denied for user 'dbusr'@'172.17.0.1' (using password: YES)
 [exec]   at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:238)
 [exec]   at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:171)
 [exec]   at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1128)
 [exec]   at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:560)
 [exec]   at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:174)
 [exec]   at org.mariadb.jdbc.Driver.connect(Driver.java:92)
 [exec]   at java.sql.DriverManager.getConnection(DriverManager.java:664)
 [exec]   at java.sql.DriverManager.getConnection(DriverManager.java:208)
 [exec]   at shared.ConnectionPool.createConnectionOnServer(ConnectionPool.java:983)
 [exec]   at shared.ConnectionPool.createConnection(ConnectionPool.java:867)
 [exec]   at shared.ConnectionPool.leaseConnection(ConnectionPool.java:626)
 [exec]   at shared.ConnectionPool.leaseConnection(ConnectionPool.java:679)
 [exec]   at serverbridge.tomcat.TomcatConnectionManager.getConnection(TomcatConnectionManager.java:156)
 [exec]   at serverbridge.tomcat.TomcatConnectionManager.<init>(TomcatConnectionManager.java:71)
 [exec]   ... 13 more
 [exec] Caused by: java.sql.SQLException: Access denied for user 'dbusr'@'172.17.0.1' (using password: YES)
 [exec] Current charset is UTF-8. If password has been set using other charset, consider using option 'passwordCharacterEncoding'

I don't think this is an encoding issue although this is clearly what the error says. I've played about with it a bit and searched online and although I can see similar issues I'm not really sure where to go next. Can anyone offer any suggestions ?

I haven't made the my.conf files match ytet, I guess this is my next step but there doesn't seem to be much difference and nothing to do with password encoding (or any encoding really)

1 Answers

I have had a similar issue in the past. The resolution involved creating the user 'dbuser@172.17.0.1' (or whatever the host IP is) in the database users table. Then grant it permissions rather than just granting access for 'dbuser' or 'dbuser@localhost'.

Related