Uploaded image for project: 'Percona Monitoring and Management'
  1. Percona Monitoring and Management
  2. PMM-4879

Ability to read connection details from MySQL config file passed by --defaults-file flag


    • 3
    • Yes
    • Yes
    • Yes
    • No
    • [obsolete] Implex


      The following have not been implemented:

      • --defaults-file

      The absence of the ability to use a Mysql Config (my.cnf) file for connection config is bad for automation:

      • it forces a password to be set in the command line
      • it leads to the possibility that the password appears in logs and is shipped off somewhere
      • it removes the ability to check if a password should change by detecting a change in the cnf file

      Use case

      As PMM user I need to be able to specify  --defaults-file flag as a path to .cnf file so that I can skip passing --user-name and --password  options while adding DB and they will be extracted from config file 


      Acceptance criteria:

      • User able to specify a path to defaults file
      • If username and password is passed along with defaults path, the flags have highest priority and values (username and password) from file are ignored
      • Parsing defaults file should be done by pmm-agent****


      pmm-admin add mysql --defaults-file=~/my.sandbox.cnf  MyDB 

       Also, Feature should be available by API (for future UI  improvements) and follow common logic - implement logic in pmm-agent, not  pmm-admin 


      • this is username and password related. We are not adding support of other fields from config file
      • If password changed  - user need to re-add Service to the system, as it goes with usual --password/–username  flags 

      Out of scope:

      • Handling encrypted credentials.

      Suggested solution:

      • Add --defaults-file flag to pmm-admin add mysql command
      • Add new field `defaults_file` to management API for MySQL
      • Add new action to extract credentials from defaults file
      • Extract username and password on pmm-agent side
        • Use ini parser for it.
      • Return Username and password from the action
      • Save returned username and password to agent model
      • Check connection


      How to test:

      1. Run PMM server.
      2. Run MySQL.
      3. Run PMM agent and prepare defaults file. e.g.:


      Please remember to change credentials for proper one for MySQL database.
      4. Use pmm-admin with --defaults-file parameter and path to file 

      pmm-admin add mysql --defaults-file=~/.my.cnf 

      5. You can replace username/password just to check if have highest priority:

      pmm-admin add mysql --defaults-file=~/.my.cnf --username=bad 
      pmm-admin add mysql --defaults-file=~/.my.cnf --password=wrong

      6. It should throws credentials error during connection test


        Issue Links



              przemyslaw.kadej Przemyslaw Kadej (Inactive)
              ceri.williams Ceri Williams
              0 Vote for this issue
              8 Start watching this issue



                Time Tracking

                  Original Estimate - Not Specified
                  Not Specified
                  Remaining Estimate - Not Specified
                  Not Specified
                  Time Spent - 20 minutes

                  Smart Checklist