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

mysql_install_db "Could not find ./bin/my_print_defaults"

Details

    • 10.1.32

    Description

      a default compiled mariadb (CMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql) installed, with make install.

      path set:

      $ export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/scripts
       
      $ mysql_install_db --defaults-file=~/my.cnf --datadir=~/data2
       
      FATAL ERROR: Could not find ./bin/my_print_defaults
      

      A work around is to include `--basedir=/usr/local/mysql` in the mysql_install_db options however this should be default on an install.

      Recently changed in all versions (though problem probably existed before hand).
      https://github.com/MariaDB/server/commit/52516706c86f9f66c76836eabde7e2477694bac3

      Attachments

        Issue Links

          Activity

            I think it could've been fixed simpler, by not resetting $basedir:

            diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
            --- a/scripts/mysql_install_db.sh
            +++ b/scripts/mysql_install_db.sh
            @@ -251,8 +251,11 @@ then
                 cannot_find_file my_print_defaults $basedir/bin $basedir/extra
                 exit 1
               fi
            -else
            +elif test -x "@bindir@/my_print_defaults"
               print_defaults="@bindir@/my_print_defaults"
            +else
            +then
            +  basedir="@CMAKE_INSTALL_PREFIX@"
            +  print_defaults="@CMAKE_INSTALL_PREFIX@/@bindir@/my_print_defaults"
             fi
             
             if test ! -x "$print_defaults"
            

            But should it default to /usr/loca//mysql? tarball is supposed to be fully relocatable, it can be unpacked anywhere. I don't know if it's safe to assume that it'll be unpacked into /usr/local/mysql.

            serg Sergei Golubchik added a comment - I think it could've been fixed simpler, by not resetting $basedir : diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -251,8 +251,11 @@ then cannot_find_file my_print_defaults $basedir/bin $basedir/extra exit 1 fi -else +elif test -x "@bindir@/my_print_defaults" print_defaults="@bindir@/my_print_defaults" +else +then + basedir="@CMAKE_INSTALL_PREFIX@" + print_defaults="@CMAKE_INSTALL_PREFIX@/@bindir@/my_print_defaults" fi if test ! -x "$print_defaults" But should it default to /usr/loca//mysql ? tarball is supposed to be fully relocatable, it can be unpacked anywhere. I don't know if it's safe to assume that it'll be unpacked into /usr/local/mysql .
            danblack Daniel Black added a comment -

            How about something like the following so we fall back to path if not found. At least the user can fix that without editing the instlaled file.

            diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
            index 5afeb6a6f47..eff435962d3 100644
            --- a/scripts/mysql_install_db.sh
            +++ b/scripts/mysql_install_db.sh
            @@ -285,14 +285,16 @@ then
                 cannot_find_file my_print_defaults $basedir/bin $basedir/extra
                 exit 1
               fi
            -else
            +elif test -x "@bindir@/my_print_defaults"
            +then
               print_defaults="@bindir@/my_print_defaults"
            -fi
            -
            -if test ! -x "$print_defaults"
            +elif test -x "@CMAKE_INSTALL_PREFIX@/@bindir@/my_print_defaults"
             then
            -  cannot_find_file "$print_defaults"
            -  exit 1
            +  basedir="@CMAKE_INSTALL_PREFIX@"
            +  print_defaults="@CMAKE_INSTALL_PREFIX@/@bindir@/my_print_defaults"
            +else
            +# let the path find it
            +  print_defaults="my_print_defaults"
             fi
             
             # Now we can get arguments from the groups [mysqld] and [mysql_install_db]
            

            danblack Daniel Black added a comment - How about something like the following so we fall back to path if not found. At least the user can fix that without editing the instlaled file. diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 5afeb6a6f47..eff435962d3 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -285,14 +285,16 @@ then cannot_find_file my_print_defaults $basedir/bin $basedir/extra exit 1 fi -else +elif test -x "@bindir@/my_print_defaults" +then print_defaults="@bindir@/my_print_defaults" -fi - -if test ! -x "$print_defaults" +elif test -x "@CMAKE_INSTALL_PREFIX@/@bindir@/my_print_defaults" then - cannot_find_file "$print_defaults" - exit 1 + basedir="@CMAKE_INSTALL_PREFIX@" + print_defaults="@CMAKE_INSTALL_PREFIX@/@bindir@/my_print_defaults" +else +# let the path find it + print_defaults="my_print_defaults" fi   # Now we can get arguments from the groups [mysqld] and [mysql_install_db]
            serg Sergei Golubchik added a comment - - edited

            My point is, if there's one mariadb tarball installed in /usr/local, and another one in, say, ~/mariadb-test or, for example, /usr/local/mariadb-10.3, then a user would rather prefer an error if --basedir is not specified, rarher then picking up incorrect mariadb installation automatically. After all, mysql_install_db is run only once.

            On the other hand, using the dirname $0 as a hint to guess the correct path seems pretty safe. Just need to be portable enough.

            serg Sergei Golubchik added a comment - - edited My point is, if there's one mariadb tarball installed in /usr/local , and another one in, say, ~/mariadb-test or, for example, /usr/local/mariadb-10.3 , then a user would rather prefer an error if --basedir is not specified, rarher then picking up incorrect mariadb installation automatically. After all, mysql_install_db is run only once. On the other hand, using the dirname $0 as a hint to guess the correct path seems pretty safe. Just need to be portable enough.

            danblack There were some comments from Serg. Is there something that you could change accordingly in the patch?

            ratzpo Rasmus Johansson (Inactive) added a comment - danblack There were some comments from Serg. Is there something that you could change accordingly in the patch?
            danblack Daniel Black added a comment -

            Updated PR created based purely on dirname. I haven't found any suggestion is anything other than posix.

            Related, fixes user problem, https://github.com/MariaDB/server/pull/760#issuecomment-452903667, and hopefully eliminates the need for https://git.alpinelinux.org/aports/tree/main/mariadb/fix-mysql-install-db-path.patch in alpine.

            danblack Daniel Black added a comment - Updated PR created based purely on dirname. I haven't found any suggestion is anything other than posix. Related, fixes user problem, https://github.com/MariaDB/server/pull/760#issuecomment-452903667 , and hopefully eliminates the need for https://git.alpinelinux.org/aports/tree/main/mariadb/fix-mysql-install-db-path.patch in alpine.

            People

              serg Sergei Golubchik
              danblack Daniel Black
              Votes:
              1 Vote for this issue
              Watchers:
              5 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.