[op5-users] Merlin installation - install-merlin.sh not creating mysql DB

Tom Welsh twelsh37 at gmail.com
Fri Jul 31 15:25:03 CEST 2009


Hey list,

I'm busy trying to finish off a mother of all Nagios install scripts and
have bumped into a problem with Merlins install-merlin.sh install script. Im
not sure if its a local issue with my MySQL setup or just something everyone
fixes themself?

I'm running Centos 5.2
Apache 2.2.3
Nagios 3.1.2
MySQL 5.0.45

When i run the install script I get the following error.

-----------------------------------------------<SNIP>
-----------------------------------------------

[root at vm1:/tmp/nagios/merlin-0.6.2-beta2.p1 ] # /bin/sh install-merlin.sh
--dest-dir=/usr/local/nagios/merlin
--nagios-cfg=/usr/local/nagios/etc/nagios.cfg --db-type=mysql
--db-user=merlin --db-pass=PASSWORD --db-name=merlin
  Database settings:
    Type     (--db-type): mysql
    Name     (--db-name): merlin
    Username (--db-user): merlin
    Password (--db-pass): PASSWORD

  Path settings:
    Nagios config file  (--nagios-cfg): /usr/local/nagios/etc/nagios.cfg
    Destination directory (--dest-dir): /usr/local/nagios/merlin
    Base root                 (--root):

  Installing the following components: db,files,config,init
Does this look ok? [Y/n] y

Installing

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: NO)
Creating database merlin
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: NO)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: NO)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: NO)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: NO)
Failed to setup database.
Aborting.
[root at vm1:/tmp/nagios/merlin-0.6.2-beta2.p1 ] #
-----------------------------------------------<SNIP>
-----------------------------------------------

So its not allowing me to create the database.

I edited the script and just stuck my user and password in for the DB admin
and it works like a dream
My question is should I have needed to do this or is it just the way I have
MySQL installed, which is basicly out of the box and configured with a root
user and password as hinted at when you first fire it up.

Every where in the script where it said "mysql -e" or "mysql" i just changed
it to "mysql -u root -pPASSWORD ..."  as you can see below.

-----------------------------------------------<SNIP>
-----------------------------------------------

db_setup ()
{
        case "$db_type" in
                mysql)
                        # Create database if it do not exist
                        if [[ ! $(mysql -u root -pPASSWORD -e "SHOW
DATABASES LIKE '$db_name'") ]]; then
                                echo "Creating database $db_name"
                                mysql -u root -pPASSWORD -e "CREATE DATABASE
IF NOT EXISTS $db_name"
                        fi
                        # Always set privileges (to be on the extra safe
side)
                        mysql -u root -pPASSWORD -e \
                          "GRANT ALL ON $db_name.* TO
$db_user at localhostIDENTIFIED BY '$db_pass'"
                        mysql -u root -pPASSWORD -e 'FLUSH PRIVILEGES'
                        # Fetch db_version and do upgrade stuff if/when
needed
                        query="SELECT version FROM db_version"
                        db_version=$(mysql -u root -pPASSWORD $db_name -BNe
"$query" 2>/dev/null)
                        case "$db_version" in
                                "")
                                        # No db installed
                                        mysql -u root -pPASSWORD $db_name <
$src_dir/db.sql
                                        ;;
                                "1")
                                        # DB Version is 1 and db should be
re-installed (According to AE)
                                        mysql -u root -pPASSWORD $db_name <
$src_dir/db.sql
                                        ;;
                                *)
                                        # Unknown version, should we handle
this?
                                        ;;
                        esac
                        ;;
                *)
                        echo "Unknown database type '$db_type'"
                        echo "I understand only lower-case database types."
                        return 0
                        ;;
        esac
}

-----------------------------------------------<SNIP>
-----------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.op5.com/pipermail/op5-users/attachments/20090731/71753d77/attachment.html 


More information about the op5-users mailing list