Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-8498

mysql_secure_installation can't find "mysql" in basedir

Details

    • 10.0.22

    Description

      If the "mysql" client is not found in $PATH, then mysql_secure_installation won't find it from in basedir:

      [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
      print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults
       
      FATAL ERROR: Could not find mysql
       
      The following directories were searched:
       
      /tmp/mariadb-10.1.5-linux-x86_64//bin
       
      If you compiled from source, you need to run 'make install' to
      copy the software into the correct location ready for operation.
       
      If you are using a binary release, you must either be at the top
      level of the extracted archive, or pass the --basedir option
      pointing to that location.

      But it will find it if added to $PATH:

      [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ export PATH=$PATH:/tmp/mariadb-10.1.5-linux-x86_64/bin
      [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
      print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults
       
      NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
       
      In order to log into MariaDB to secure it, we'll need the current
      password for the root user. If you've just installed MariaDB, and
      you haven't set the root password yet, the password will be blank,
      so you should just press enter here.
       
      Enter current password for root (enter for none):

      I think the bug happens because bindir is set to use basedir here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L176

      But then find_in_basedir is called here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L184

      Which adds basedir to the path again here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L83

      So if basedir is /usr/local/mysql, it will search for /usr/local/mysql/usr/local/mysql/bin/mysql.

      Attachments

        Issue Links

          Activity

            GeoffMontee Geoff Montee (Inactive) created issue -
            GeoffMontee Geoff Montee (Inactive) made changes -
            Field Original Value New Value
            Description If the "mysql" client is not found in $PATH, then mysql_secure_installation won't find it from in basedir:

            {code}
            This appears to be a bug. I've reproduced it on my end. I'll submit a JIRA issue.

            If it really is checking that directory, I'm not yet sure why it isn't finding the mysql binary. Regardless, temporarily adding MariaDB's bin directory to $PATH got it to work for me.

            [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
            print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults

            FATAL ERROR: Could not find mysql

            The following directories were searched:

            /tmp/mariadb-10.1.5-linux-x86_64//bin

            If you compiled from source, you need to run 'make install' to
            copy the software into the correct location ready for operation.

            If you are using a binary release, you must either be at the top
            level of the extracted archive, or pass the --basedir option
            pointing to that location.
            {code}

            But it will find it if added to $PATH:

            {code}
            [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ export PATH=$PATH:/tmp/mariadb-10.1.5-linux-x86_64/bin
            [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
            print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults

            NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
            SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

            In order to log into MariaDB to secure it, we'll need the current
            password for the root user. If you've just installed MariaDB, and
            you haven't set the root password yet, the password will be blank,
            so you should just press enter here.

            Enter current password for root (enter for none):
            {code}

            I think the bug happens because bindir is set to use basedir here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L176

            But then find_in_basedir is called here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L184

            Which adds basedir to the path again here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L83

            So if basedir is /usr/local/mysql, it will search for /usr/local/mysql/usr/local/mysql/bin/mysql.
            If the "mysql" client is not found in $PATH, then mysql_secure_installation won't find it from in basedir:

            {code}
            [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
            print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults

            FATAL ERROR: Could not find mysql

            The following directories were searched:

            /tmp/mariadb-10.1.5-linux-x86_64//bin

            If you compiled from source, you need to run 'make install' to
            copy the software into the correct location ready for operation.

            If you are using a binary release, you must either be at the top
            level of the extracted archive, or pass the --basedir option
            pointing to that location.
            {code}

            But it will find it if added to $PATH:

            {code}
            [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ export PATH=$PATH:/tmp/mariadb-10.1.5-linux-x86_64/bin
            [gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
            print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults

            NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
            SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

            In order to log into MariaDB to secure it, we'll need the current
            password for the root user. If you've just installed MariaDB, and
            you haven't set the root password yet, the password will be blank,
            so you should just press enter here.

            Enter current password for root (enter for none):
            {code}

            I think the bug happens because bindir is set to use basedir here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L176

            But then find_in_basedir is called here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L184

            Which adds basedir to the path again here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L83

            So if basedir is /usr/local/mysql, it will search for /usr/local/mysql/usr/local/mysql/bin/mysql.
            elenst Elena Stepanova made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            elenst Elena Stepanova made changes -
            Fix Version/s 10.1 [ 16100 ]
            Fix Version/s 10.0 [ 16000 ]
            elenst Elena Stepanova made changes -
            Assignee Michael Widenius [ monty ]
            serg Sergei Golubchik made changes -
            Assignee Michael Widenius [ monty ] Sergey Vojtovich [ svoj ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.0.22 [ 17 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Rank Ranked higher

            serg, please review fix for this bug.

            svoj Sergey Vojtovich added a comment - serg , please review fix for this bug.
            svoj Sergey Vojtovich made changes -
            Assignee Sergey Vojtovich [ svoj ] Sergei Golubchik [ serg ]
            Status Confirmed [ 10101 ] In Review [ 10002 ]

            ok to push

            serg Sergei Golubchik added a comment - ok to push
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Sergey Vojtovich [ svoj ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            svoj Sergey Vojtovich made changes -
            Fix Version/s 10.0.22 [ 19700 ]
            Fix Version/s 10.1.9 [ 20301 ]
            Fix Version/s 10.0 [ 16000 ]
            Fix Version/s 10.1 [ 16100 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            svoj Sergey Vojtovich made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 70675 ] MariaDB v4 [ 149395 ]

            People

              svoj Sergey Vojtovich
              GeoffMontee Geoff Montee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.