username & password for cli

Hi all

I am super happy with flyway and we are using it to migrate our database to new versions.
For testing, I use the windows-cli to execute the migrations on databases. Usually, I have the URL, Schema etc. as parameter in a config file but do not configure username and password in this config-file.
I run "flyway migrate" on the command-line and get prompted for the username and password.

Sadly, in the newest version 10.3.0 (as well as 10.2.0) the prompted username and password does not seem to be passed to the JDBC connection and I only get the following error:
ERROR: Unable to obtain connection from database (jdbc:postgresql://xx.xx.xx:xxxx/db) for user 'null': The server requested password-based authentication, but no password was provided by plugin null
If I configure the username and password in the configuration-file (with flyway.user= and flyway.password=) all works fine.

Am I doing something wrong or is there a problem?

Thanks for your answers and Merry Christmas!
Tagged:

Answers

  • Peter_LawsPeter_Laws Posts: 289 Silver 2
    edited December 18, 2023 10:51AM
    Merry Christmas to you too aremund, delighted to hear that flyway is working well for you (aside from this little blip).

    Please can you clarify, on the command line are calling the connection like this
    flyway migrate <url> <user> <password>
    or 
    flyway migrate <url>
    and then expecting flyway to prompt you for credentials interactively?
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • aremundaremund Posts: 3 New member
    Hi @Peter_Laws

    Thanks a lot for checking on my problem and sorry for the late response.

    If I am calling the connection with username and password as a parameter, everything works fine:
    C:\some\path>flyway info -user=username -password=password
    Flyway Community Edition 10.4.0 by Redgate
    
    See release notes here: https://rd.gt/416ObMi
    739 SQL migrations were detected but not run because they did not follow the filename convention.
    Set 'validateMigrationNaming' to true to fail fast and see a list of the invalid file names.
    Database: jdbc:postgresql://xxx.xxx.xx:5432/db (PostgreSQL 15.4)
    
    You are not signed in to Flyway, to sign in please run auth
    Schema version: 3.9.1
    
    +------------+-----------+---------------------------------------------------------------------------------------------------------------+------+---------------------+------------+----------+
    | Category   | Version   | Description                                                                                                   | Type | Installed On        | State      | Undoable |
    +------------+-----------+---------------------------------------------------------------------------------------------------------------+------+---------------------+------------+----------+
    <...more output...>
    However, I try to avoid entering the password directly on the command-line and prefer flyway prompting me for the password. If I am doing that, the password does not seem to be passed to the connection:
    C:\dev\ws-mono\bertschi-g11\pmodel>flyway info -user=username
    Database password: <I get prompted and enter the password here>
    Flyway Community Edition 10.4.0 by Redgate
    
    See release notes here: https://rd.gt/416ObMi
    739 SQL migrations were detected but not run because they did not follow the filename convention.
    Set 'validateMigrationNaming' to true to fail fast and see a list of the invalid file names.
    ERROR: Unable to obtain connection from database (jdbc:postgresql://xxx.xxx.xx:5432/db) for user 'username': The server requested password-based authentication, but no password was provided by plugin null
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL State  : 08004
    Error Code : 0
    Message    : The server requested password-based authentication, but no password was provided by plugin null
    
    Caused by: org.postgresql.util.PSQLException: The server requested password-based authentication, but no password was provided by plugin null

    I hope that clarifies further about my problem.

    Kind regards,
    Alain
  • Thank you for the added detail Alain, I've now replicated the issue and raised it for the developers to correct.
    I'll keep you posted.
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • Hello aremund,

    After reviewing the functionality and the minimal documentation regarding, it's been concluded that this legacy behaviour is rather antithetical to tooling's intent and should be deprecated in the near future as there are now much better and more reliable means with which to achieve the same result.

    This is detailed in greater depth here.
    https://documentation.red-gate.com/flyway/flyway-blog/deprecation-of-flyway-s-interactive-behavior

    I recognise this isn't what you asked and I apologise for that, I'm hopeful that the alternatives will be superior. Should you have any issues implementing the alternatives, please do reach out! 
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
  • aremundaremund Posts: 3 New member
    Hi @Peter_Laws

    Thanks for the clear answer. Of course it is a bit unfortunate for my case but your reasoning is well explained in the linked blog-entry.

    Thanks a lot and keep up the good work!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file