Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Running mysql source as a mysqld service in redhat AS 4.0

  • 20-09-2005 7:04am
    #1
    Closed Accounts Posts: 658 ✭✭✭


    Hi

    Im having problems installing MySQL on redhat as an RPM binary, so that aside, I am compiling it from source and installing it that way, which seems to me to work much better. Now the problem I have is that I need to have MySQL running as a daemon in order for another program to stop complaining that it can't locate a running instance of mysqld. After installing MySQL from source, how can I start it by typing '/sbin/service mysqld start' instead of typing ./mysqld_safe --user=mysql' ? Thanks for any help in advance.


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Just copy the /etc/rc.d/init.d/mysqld script from the RPM version, chmod it 755, adjust the paths if they're different, and run `chkconfig mysqld on`. Here's mine from ES3:
    #!/bin/bash
    #
    # mysqld        This shell script takes care of starting and stopping
    #               the MySQL subsystem (mysqld).
    #
    # chkconfig: - 78 12
    # description:  MySQL database server.
    # processname: mysqld
    # config: /etc/my.cnf
    # pidfile: /var/run/mysqld/mysqld.pid
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Source networking configuration.
    . /etc/sysconfig/network
    
    
    prog="MySQL"
    
    datadir="/var/lib/mysql"
    
    start(){
            touch /var/log/mysqld.log
            chown mysql.mysql /var/log/mysqld.log
            chmod 0640 /var/log/mysqld.log
            if [ ! -d $datadir/mysql ] ; then
                action $"Initializing MySQL database: " /usr/bin/mysql_install_db
                ret=$?
                chown -R mysql.mysql $datadir
                if [ $ret -ne 0 ] ; then
                    return $ret
                fi
            fi
            chown -R mysql.mysql $datadir
            chmod 0755 $datadir
            /usr/bin/safe_mysqld  --defaults-file=/etc/my.cnf >/dev/null 2>&1 &
            ret=$?
            if [ $ret -eq 0 ]; then
                action $"Starting $prog: " /bin/true
            else
                action $"Starting $prog: " /bin/false
            fi
            [ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
            return $ret
    }
    
    stop(){
            /bin/kill `cat /var/run/mysqld/mysqld.pid  2> /dev/null ` > /dev/null 2>&1
            ret=$?
            if [ $ret -eq 0 ]; then
                action $"Stopping $prog: " /bin/true
            else
                action $"Stopping $prog: " /bin/false
            fi
            [ $ret -eq 0 ] && rm -f /var/lock/subsys/mysqld
            [ $ret -eq 0 ] && rm -f $datadir/mysql.sock
            return $ret
    }
    
    restart(){
        stop
        start
    }
    
    condrestart(){
        [ -e /var/lock/subsys/mysqld ] && restart || :
    }
    
    # See how we were called.
    case "$1" in
      start)
        start
        ;;
      stop)
        stop
        ;;
      status)
        status mysqld
        ;;
      restart)
        restart
        ;;
      condrestart)
        condrestart
        ;;
      *)
        echo $"Usage: $0 {start|stop|status|condrestart|restart}"
        exit 1
    esac
    
    exit $?
    


  • Closed Accounts Posts: 658 ✭✭✭pontovic


    Thanks Ken much obliged :)


Advertisement