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

establishing connection with privileged user (mysql) #682

Closed
dfreudenberger opened this issue May 4, 2018 · 5 comments
Closed

establishing connection with privileged user (mysql) #682

dfreudenberger opened this issue May 4, 2018 · 5 comments

Comments

@dfreudenberger
Copy link

Hi there,

is there any special reason why the connection is established with a user that has access to the test schema only? I'm working on an application that needs access to tables in different schemas and is using flyway to manage the migrations. Unfortunately flyway already fails because it is unable to create the schemas.

Happy to work on a pull request if this is open for change.

Best,
Daniel

@kiview
Copy link
Member

kiview commented May 5, 2018

Hi @dfreudenberger,

We are using the official MySQL image.
Testcontainers itself is not really establishing the connection, it provides accessors and convenience methods (getJdbcUrl()) to allow your system to connect to database inside the container.

If you want root access to the database, you can use (the hardcoded) username "root" with password "test". Would this work for your use case? And does your use case involve creating different schemas?

@dfreudenberger
Copy link
Author

Hi @kiview

thank for getting back to me quickly. As of right now I'm relying on the jdbc url modification in order to start the docker container and it seems like there is no way to provide a username and password for the connection. Maybe this is something that could be build on top of this PR #617

Best,
Daniel

@kiview
Copy link
Member

kiview commented May 6, 2018

Hey @dfreudenberger,
thanks for the clarification, I see the problem now.
I'm not sure of the current state of the ContainerDatabaseDriver class, which is responsible for parsing the connection string, launching the container, connecting, etc. and not too familiar with its implementation, but have you tried encoding the root user and password in the JDBC Url?
Like
jdbc:tc:mysql:5.6.23://somehostname:someport/databasename?user=root&password=test

Else adding this feature after merging the mentioned PR would definitely make sense.

@dfreudenberger
Copy link
Author

Hey again,

adding user or password to the query string doesn't have any effect. I'll wait until the PR is merged and will provide a pull request afterwards.

Best

@patrickbray
Copy link

If you want root access to the database, you can use (the hardcoded) username "root" with password "test". Would this work for your use case? And does your use case involve creating different schemas?

@kiview Sorry to comment on an old thread but your comment seems related to what I am trying to achieve here https://stackoverflow.com/questions/65031662/mysql-testcontainers-init-script-schema-creation-failing is there anyway to create schemas in a mysql test containers instance or do I need to run a custom image with these pre-created?

I tried connecting as root / test but this seems to hang the container startup.

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

No branches or pull requests

3 participants