Bug #59563 mysql_install_db does not prepare databases correctly
Submitted: 17 Jan 2011 18:07 Modified: 18 Jan 2011 6:06
Reporter: Matthias Stumpp Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S1 (Critical)
Version:mysql-cluster-gpl-7.1.9a OS:Linux (AWS EC2 AMI)
Assigned to: CPU Architecture:Any

[17 Jan 2011 18:07] Matthias Stumpp
Description:
I compiled from source with the options see below. No errors...

When running mysql_install_db, I get the following output:

<----

Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql_cluster_3310/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql_cluster_3310/bin/mysqladmin -u root -h ip-10-116-145-115 password 'new-password'

Alternatively you can run:
/usr/local/mysql_cluster_3310/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql_cluster_3310 ; /usr/local/mysql_cluster_3310/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql_cluster_3310/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql_cluster_3310/bin/mysqlbug script!
<--

Everything seems ok. However, when executing "mysqld_safe --defaults-file=/usr/local/mysql_cluster_3310/my.cnf --user=mysql", mysqld fails to start up. 

The following lines have been written to the log:

110117 17:57:44 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql_cluster_3310/data
110117 17:57:44 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
/usr/local/mysql_cluster_3310/libexec/mysqld: Table 'mysql.plugin' doesn't exist
110117 17:57:44 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110117 17:57:44 [Note] Starting Cluster Binlog Thread
110117 17:57:44 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
110117 17:57:44 mysqld_safe mysqld from pid file /usr/local/mysql_cluster_3310/data/ip-10-116-145-115.pid ended

According to the log, several tables are missing, although mysql_install_db doesn't output any problems...

Trying to run mysql_install_db a second time results in:

<--
Installing MySQL system tables...
ERROR: 1005  Can't create table 'ndb$tables' (errno: 13)
110117 18:06:23 [ERROR] Aborting

110117 18:06:23 [Note] /usr/local/mysql_cluster_3310/libexec/mysqld: Shutdown complete

Installation of system tables failed!  Examine the logs in
/usr/local/mysql_cluster_3310/var for more information.

You can try to start the mysqld daemon with:
...
<--

(Doesen't men anything, but the same installation routine works fine for mysql-5.5.8-linux2.6-i686) 

How to repeat:
- tar zxvf mysql-cluster-gpl-7.1.9a.tar.gz
- mv mysql-cluster-gpl-7.1.9a mysql-cluster-gpl-7.1.9a_3310
- ln -s mysql-cluster-gpl-7.1.9a_3310/ mysql_cluster_3310
- cd mysql_cluster_3310
- ./configure --datadir=/usr/local/mysql_cluster_3310/data --with-tcp-port=3310 --with-unix-socket-path=/tmp/mysql_cluster_3310.sock --prefix=/usr/local/mysql_cluster_3310 --with-mysqld-user=mysql --with-plugins=ndbcluster
- make
- make install
- chown -R mysql .
- chgrp -R mysql .
- cp support-files/my-small.cnf /usr/local/mysql_cluster_3310/my.cnf 
- cd scripts
- chmod -R 777 mysql_install_db
- cd ../
- scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql_cluster_3310 --datadir=/usr/local/mysql_cluster_3310/data --defaults-file=/usr/local/mysql_cluster_3310/my.cnf
- scripts/mysql_install_db --user=mysql
- chown -R root .
- chown -R mysql data
- bin/mysqld_safe --defaults-file=/usr/local/mysql_cluster_3310/my.cnf --user=mysql &
[17 Jan 2011 21:27] Sveta Smirnova
Thank you for the report.

Please provide output of `ls /usr/local/mysql_cluster_3310/data` and `ls /usr/local/mysql_cluster_3310/data/mysql`
[17 Jan 2011 21:56] Matthias Stumpp
"ls /usr/local/mysql_cluster_3310/data" shows:

drwxr-xr-x  3 mysql mysql 4096 Jan 17 17:57 .
drwxr-xr-x 39 root  mysql 4096 Jan 17 17:56 ..
-rw-rw----  1 mysql root   703 Jan 17 17:57 ip-10-116-145-115.err
drwxr-xr-x 26 mysql mysql 4096 Jan 17 17:48 mysql

"ls /usr/local/mysql_cluster_3310/data/mysql" shows:

drwxr-xr-x 26 mysql mysql   4096 Jan 17 17:48 .
drwxr-xr-x  3 mysql mysql   4096 Jan 17 17:57 ..
-rw-r--r--  1 mysql mysql 507636 Jan 17 17:47 ChangeLog
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 charsets
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 czech
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 danish
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 dutch
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 english
-rw-r--r--  1 mysql mysql 416601 Jan 17 17:48 errmsg.txt
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 estonian
-rw-r--r--  1 mysql mysql 607148 Jan 17 17:47 fill_help_tables.sql
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 french
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 german
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 greek
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 hungarian
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 italian
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 japanese
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 korean
-rw-r--r--  1 mysql mysql   5006 Jan 17 17:47 mi_test_all
-rw-r--r--  1 mysql mysql   1517 Jan 17 17:47 mi_test_all.res
-rw-r--r--  1 mysql mysql  61972 Jan 17 17:47 mysql_fix_privilege_tables.sql
-rw-r--r--  1 mysql mysql   2058 Jan 17 17:47 mysql_system_tables_data.sql
-rw-r--r--  1 mysql mysql  34558 Jan 17 17:47 mysql_system_tables.sql
-rw-r--r--  1 mysql mysql   9669 Jan 17 17:47 mysql_test_data_timezone.sql
-rw-r--r--  1 mysql mysql  17983 Jan 17 17:48 ndbinfo.sql
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 norwegian
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 norwegian-ny
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 polish
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 portuguese
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 romanian
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 russian
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 serbian
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 slovak
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 spanish
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 swedish
drwxr-xr-x  2 mysql mysql   4096 Jan 17 17:48 ukrainian
[18 Jan 2011 1:22] Sveta Smirnova
Thank you for the feedback.

Verified as described. This is compilation problem: if compile with options provided shared files installed in the directory specified as datadir.