Bug #36221 mysql_install_db wants to create directories outside of $PREFIX
Submitted: 20 Apr 2008 8:42 Modified: 30 May 2008 11:31
Reporter: Sebastian Bergmann Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:6.0 OS:Linux
Assigned to: Assigned Account CPU Architecture:Any
Tags: mysql_install_db

[20 Apr 2008 8:42] Sebastian Bergmann
Description:
sb@ubuntu mysql-6.0 % ./scripts/mysql_install_db
mkdir: cannot create directory `/var/lib/mysql/test': Permission denied
chmod: cannot access `/var/lib/mysql/test': No such file or directory
Installing MySQL system tables...
080420 10:40:03 [Warning] /usr/sbin/mysqld: unknown option '--loose-skip-innodb'

080420 10:40:03 [Warning] /usr/sbin/mysqld: unknown option '--loose-skip-ndbcluster'

080420 10:40:03 [Warning] Can't create test file /var/lib/mysql/ubuntu.lower-test
080420 10:40:03 [Warning] Can't create test file /var/lib/mysql/ubuntu.lower-test
080420 10:40:03  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

Installation of system tables failed!  Examine the logs in
/var/lib/mysql for more information.

You can try to start the mysqld daemon with:

    shell> /usr/sbin/mysqld --skip-grant &

and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> /usr/bin/mysql -u root mysql
    mysql> show tables

Try 'mysqld --help' if you have problems with paths.  Using --log
gives you a log in /var/lib/mysql that may be helpful.

The latest information about MySQL is available on the web at
http://www.mysql.com/.  Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before mailing us!  And remember, if
you do mail us, you MUST use the /usr/scripts/mysqlbug script!

How to repeat:
shell> bkf clone bk://mysql.bkbits.net/mysql-6.0 mysql-6.0
shell> cd mysql-6.0
shell> ./BUILD/compile-pentium --prefix=/usr/local/mysql-6.0
shell> make install
shell> ./scripts/mysql_install_db
[20 Apr 2008 9:24] Hakan Küçükyılmaz
Sebastian,

please verify that you have no /etc/my.cnf or /etc/mysql/my.cnf on your system. If so, then please try with --no-defaults as first option.

Best regards,

Hakan
[20 Apr 2008 9:35] Sebastian Bergmann
Okay, with --no-defaults it works.

Not it is arguable whether --no-defaults should be the default behaviour. At least to me it would be more intuitive to have mysql_install_db create the system tables in the directory I specified as $PREFIX by default.
[20 Apr 2008 10:07] Sebastian Bergmann
Also imagine what would happen if the user had the privileges required to write to /var/lib/mysql: kaboom.
[20 Apr 2008 10:23] Sebastian Bergmann
Just noticed that --no-defaults does not show up in mysql_install_db --help:

sb@ubuntu mysql-6.0 % ./scripts/mysql_install_db --help
Usage: ./scripts/mysql_install_db [OPTIONS]
  --basedir=path       The path to the MySQL installation directory.
  --builddir=path      If using --srcdir with out-of-directory builds, you
                       will need to set this to the location of the build
                       directory where built files reside.
  --cross-bootstrap    For internal use.  Used when building the MySQL system
                       tables on a different host than the target.
  --datadir=path       The path to the MySQL data directory.
  --force              Causes mysql_install_db to run even if DNS does not
                       work.  In that case, grant table entries that normally
                       use hostnames will use IP addresses.
  --ldata=path         The path to the MySQL data directory. Same as --datadir.
  --rpm                For internal use.  This option is used by RPM files
                       during the MySQL installation process.
  --skip-name-resolve  Use IP addresses rather than hostnames when creating
                       grant table entries.  This option can be useful if
                       your DNS does not work.
  --srcdir=path        The path to the MySQL source directory.  This option
                       uses the compiled binaries and support files within the
                       source tree, useful for if you don't want to install
                       MySQL yet and just want to create the system tables.
  --user=user_name     The login username to use for running mysqld.  Files
                       and directories created by mysqld will be owned by this
                       user.  You must be root to use this option.  By default
                       mysqld runs using your current login name and files and
                       directories that it creates will be owned by you.

All other options are passed to the mysqld program
[30 Apr 2008 7:14] Monty Taylor
I agree about a sensible default install location based on $prefix. It certainly should not just try /usr/local/mysql.
[30 Apr 2008 7:20] Monty Taylor
ldata="@localstatedir@"

It does default to your configured location... I'm guessing that you actually did have a my.cnf somewhere accessible on your system. 

I do not think that it's a good idea to turn on --no-defaults by default, since this breaks normal expected behavior. 

I _do_ think that basedir should not default to "", but rather should default to something based on $prefix (like perhaps prefix).
[30 Apr 2008 7:22] Monty Taylor
One more annoying note from me - Sebastian, I notice you are on ubuntu. If you have the package mysql-common installed, this installed the default ubuntu my.cnf file into /etc/mysql/my.cnf. There is an ongoing discussion about this, as it seems to continue to cause people grief...
[30 Apr 2008 11:31] MySQL Verification Team
Changing to need feedback to last comment of Monty: /etc/mysql/my.cnf.
Please verify. Thanks in advance.
[30 May 2008 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".