Skip to content

mysql_user.present does not work with MySQL 5.7 #29265

Closed

Description

@mbochenk

On CentOS6 mysql user is no longer created correctly, whether password or password_hash is used.
For example:

mysql-user-add-{{user.user}}-{{host}}:
  mysql_user.present:
    - name: {{user.user}}
    - password_hash: '{{user.password_hash}}'
    - host: '{{host}}'

results in:

          ID: mysql-user-add-mysql-test-localhost
    Function: mysql_user.present
        Name: mysql-test
      Result: False
     Comment: MySQL Error 1054: Unknown column 'Password' in 'where clause'
     Started: 05:46:35.532327
    Duration: 5.064 ms

This is most likely related to changes in MySQL 5.7: https://dev.mysql.com/doc/refman/5.7/en/account-upgrades.html

Salt versions report:

           Salt: 2015.5.6
         Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
         Jinja2: 2.8
       M2Crypto: 0.20.2
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.11
          ioflo: Not Installed
          PyZMQ: 14.5.0
           RAET: Not Installed
            ZMQ: 4.0.5
           Mako: Not Installed
        Tornado: Not Installed
        timelib: 0.2.4
       dateutil: Not Installed

Activity

  1. mbochenk commented on Nov 30, 2015

    @mbochenk
    Author

    Packages installed:

    MySQL-python.x86_64                   1.2.3-0.3.c1.1.el6                @base   
    mysql-community-client.x86_64         5.7.9-1.el6                       @mysql57
    mysql-community-common.x86_64         5.7.9-1.el6                       @mysql57
    mysql-community-libs.x86_64           5.7.9-1.el6                       @mysql57
    mysql-community-libs-compat.x86_64    5.7.9-1.el6                       @mysql57
    mysql-community-server.x86_64         5.7.9-1.el6                       @mysql57
    mysql-connector-python.x86_64         2.1.3-1.el6                       @mysql-connectors
    
  2. added
    bug
    severity-medium
    P2
    Platform
    on Dec 1, 2015
  3. added this to the Approved milestone on Dec 1, 2015
  4. jfindlay commented on Dec 1, 2015

    @jfindlay
    Contributor

    @mbochenk, thanks for the report.

  5. added a commit that references this issue on Jan 25, 2016
  6. rallytime commented on Jan 26, 2016

    @rallytime
    Contributor

    @mbochenk This looks to be fixed by #30603. Are you in a position to give that a try?

  7. added
    fixed-pls-verify
    on Jan 26, 2016
  8. mbochenk commented on Jan 28, 2016

    @mbochenk
    Author

    @rallytime not sure how to use it. Should I set password_column to "authentication_string" - or this should be Plugin?

  9. rallytime commented on Jan 28, 2016

    @rallytime
    Contributor

    @mbochenk After applying the change, I think you should be able to just run the state again, as is. Is that correct @michalsuba?

  10. michalsuba commented on Jan 28, 2016

    @michalsuba
    Contributor

    @mbochenk @rallytime for old databases, it should run as is, on 5.7 it should by used with

  11. mbochenk commented on Jan 29, 2016

    @mbochenk
    Author

    @michalsuba @rallytime
    Used password_column set to auth string. It works for a new user, but does not work for password changes on exisiting users. I've changed password for mysql-test user and ran state again:

    [DEBUG   ] Doing query: SELECT User,Host FROM mysql.user WHERE User = %(user)s AND Host = %(host)s AND authentication_string = %(password)s args: {'host': 'localhost', 'password': '*AB5185559FB7492CD44D9C83FC92AFC184309AFD', 'user': 'mysql-test'}
    [DEBUG   ] Doing query: SELECT User,Host FROM mysql.user WHERE User = %(user)s AND Host = %(host)s args: {'host': 'localhost', 'user': 'mysql-test'}
    [DEBUG   ] Doing query: UPDATE mysql.user SET password=%(password)s WHERE User=%(user)s AND Host = %(host)s; args: {'host': 'localhost', 'password': '*AB5185559FB7492CD44D9C83FC92AFC184309AFD', 'user': 'mysql-test'}
    [ERROR   ] MySQL Error 1054: Unknown column 'password' in 'field list'
    [ERROR   ] Failed to change password for user mysql-test@localhost (MySQL Error 1054: Unknown column 'password' in 'field list')
    
  12. rallytime commented on Feb 11, 2016

    @rallytime
    Contributor

    @mbochenk Just to clarify...did you test both of the pull requests from @michalsuba above, or just the first one? I am trying to gauge if more work is needed here, or if the second PR takes care of the issue with using password changes on existing users.

  13. mbochenk commented on Feb 12, 2016

    @mbochenk
    Author

    @rallytime I tested commit f364fbf

  14. mbochenk commented on Feb 12, 2016

    @mbochenk
    Author

    And commit 727c138 does not seem to be merged yet.

  15. rallytime commented on Feb 12, 2016

    @rallytime
    Contributor

    @mbochenk Hrm...Both commits should be merged into both the 2016.3 and develop branches. If you want to wait to test this when the next feature release comes out, that is totally fine, too.

  16. steven-hadfield commented on Mar 7, 2016

    @steven-hadfield

    Will it be possible to specify the password_column globally in /etc/salt/minion?
    e.g. mysql.password_column: 'authentication_string'
    For minions were all states run against 5.7+, it'd be easier to manage rather than having conditional logic in all individual states.
    I'm guessing that would mean that we would have to check **connection_args if password_column is defined.

  17. rallytime commented on Apr 28, 2016

    @rallytime
    Contributor

    This is fixed with #32440 and will be available in the upcoming 2016.3.0 release.

  18. devster31 commented on May 29, 2016

    @devster31

    I'm still seeing this issue in 2016.3.0 with MySQL 5.7, these are my versions-report:

    • Salt Master - CentOS 7
    Salt Version:
               Salt: 2016.3.0
    
    Dependency Versions:
               cffi: 0.8.6
           cherrypy: 3.2.2
           dateutil: Not Installed
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.7.2
            libgit2: 0.21.0
            libnacl: Not Installed
           M2Crypto: 0.21.1
               Mako: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.4.7
       mysql-python: Not Installed
          pycparser: 2.14
           pycrypto: 2.6.1
             pygit2: 0.21.4
             Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
       python-gnupg: Not Installed
             PyYAML: 3.11
              PyZMQ: 14.7.0
               RAET: Not Installed
              smmap: Not Installed
            timelib: Not Installed
            Tornado: 4.2.1
                ZMQ: 4.0.5
    
    System Versions:
               dist: centos 7.2.1511 Core
            machine: x86_64
            release: 3.10.0-327.18.2.el7.x86_64
             system: Linux
            version: CentOS Linux 7.2.1511 Core
    
    • Salt Minion - Ubuntu 16.04
    Salt Version:
               Salt: 2016.3.0
    
    Dependency Versions:
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 2.4.2
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.8
            libgit2: Not Installed
            libnacl: Not Installed
           M2Crypto: Not Installed
               Mako: 1.0.3
       msgpack-pure: Not Installed
     msgpack-python: 0.4.6
       mysql-python: 1.3.7
          pycparser: Not Installed
           pycrypto: 2.6.1
             pygit2: Not Installed
             Python: 2.7.11+ (default, Apr 17 2016, 14:00:29)
       python-gnupg: Not Installed
             PyYAML: 3.11
              PyZMQ: 15.2.0
               RAET: Not Installed
              smmap: Not Installed
            timelib: Not Installed
            Tornado: 4.2.1
                ZMQ: 4.1.4
    
    System Versions:
               dist: Ubuntu 16.04 xenial
            machine: x86_64
            release: 4.4.0-22-generic
             system: Linux
            version: Ubuntu 16.04 xenial
    
  19. rallytime commented on Jun 1, 2016

    @rallytime
    Contributor

    @neil-williamson Would it be possible for you to take another look here, based on the feedback from @devster31?

  20. neil-williamson commented on Jun 1, 2016

    @neil-williamson

    Turns out I fixed the module without checking the mysql_user state that depends on it, which was still defaulting to an explicit column name and passing it through to the module, instead of letting the module pick a default. Hopefully PR #33690 should take care of it - I tested the state this time and the fix works on my end.

  21. devster31 commented on Jun 2, 2016

    @devster31

    I applied the patch on the minion and it seems to be fixed here too.

  22. rallytime commented on Jun 2, 2016

    @rallytime
    Contributor

    Excellent! Thanks for the quick fix @neil-williamson and for following up @devster31! I'll close this back up again as I just merged the fix.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Execution-ModuleP2Platformbugfixed-pls-verifyseverity-medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions