LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-07-2002, 01:06 AM   #1
rosko
Member
 
Registered: Sep 2002
Distribution: RH8
Posts: 93

Rep: Reputation: 15
How do I add Mysql as a service in RH8?


Just curious how to add MySQL into my service list and to run as a service in RH8. I can't find my answer anywhere on the web or in the manual I have. I have installed mysql and it works fine, I just want it to run automatically on reboot and to be in the service list. Right now I just run it manually. I installed mysql 4.0.5 beta from tar.

Thanks in advance

-Jeremy
 
Old 12-07-2002, 04:09 AM   #2
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
it came with RedHat 8 as an rpm which installs the init script in /etc/rc.d/init.d


you may look and see if you have it

chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:on 5:on 6:off

if you don't have it maybe you will need to do..

chkconfig --add mysqld

and ..

chkconfig --level 345 mysqld on


/etc/rc.d/init.d/mysqld

Code:
#!/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 $?

Last edited by DavidPhillips; 12-07-2002 at 04:13 AM.
 
Old 12-07-2002, 12:35 PM   #3
rosko
Member
 
Registered: Sep 2002
Distribution: RH8
Posts: 93

Original Poster
Rep: Reputation: 15
I tryed chkconfig and it says "chkconfig: not found"..


I am a newbie and I know I'm missing something here. Could you maybe help me out a little more? Thanks a bunch.

-Jeremy
 
Old 12-07-2002, 01:23 PM   #4
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
chkconfig is in /sbin so 1. do it as root, 2. make sure it is on your path (echo $PATH) or just add "/sbin/" to the command. Did you move that script to /etc/rc.d/init.d/ ?

You might need to change a few of the paths in the script to correspond to where you installed mysql.
 
Old 12-07-2002, 02:18 PM   #5
joealaska
LQ Newbie
 
Registered: Dec 2002
Posts: 5

Rep: Reputation: 0
Add bootup/service items

Install webmin (configure for SSL after installation)
Open webmin in a browser, select the SYSTEM tab, then select BOOTUP/SHUTDOWN, find mysqld (if mysql is properly installed) and click, select "start at bootime" and be sure to save/apply at the bottom of the screen.

Life is short. Use webmin

Flames welcome
 
Old 12-07-2002, 02:26 PM   #6
joealaska
LQ Newbie
 
Registered: Dec 2002
Posts: 5

Rep: Reputation: 0
oopps

ADDON----after installation point your browser to http://127.0.0.1:10000 to access the initial login. Use your root login to access. Be sure to enter webmin configuration and set the ssl option. Instructions are included in the interface.

Once successful you will need to access via https://127.0.0.1:10000

I highly suggest cloning the root user (change username and password) then deleting the root user. Also set webmin to not offer to save password. With these few settings Webmin becomes MUCH more secure than the initial installation.

You can also set the port that webmin listens on in this area.
 
Old 12-07-2002, 07:10 PM   #7
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
If you find it's not installed,

it's on the cd or here


ftp://rpmfind.net/linux/redhat/8.0/e...3.6-3.i386.rpm




Nothing wrong with using webmin if that's what you want, but it's not your problem.

Install chkconfig and then you can get on with life

Last edited by DavidPhillips; 12-07-2002 at 07:11 PM.
 
Old 12-07-2002, 10:29 PM   #8
rosko
Member
 
Registered: Sep 2002
Distribution: RH8
Posts: 93

Original Poster
Rep: Reputation: 15
Dave, thanks a bundle for helping a winders user config mysql . Also thanks to the rest of you who posted. I used a default mysql.server script that came with a download of 4.0.5 beta. In followed Dave's instructions and it starts as a service now. The only problem I see, is when I choose "start" in the service control center, it starts mysql but the service control window hangs. Not really a big deal, as it seems to work just fine. Thanks again all .

-Jeremy
 
Old 12-07-2002, 11:03 PM   #9
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
one way to do it is to type this


/etc/rc.d/init.d/mysqld start
 
Old 12-07-2002, 11:20 PM   #10
rosko
Member
 
Registered: Sep 2002
Distribution: RH8
Posts: 93

Original Poster
Rep: Reputation: 15
Yeah, I had the same though. Just start it from putty...since logging in through x really doesn't seem as having much advantage to me. I originally wanted to login to this server remotely through X because I'm a windows guy, but now that I'm figuring out how to use linux I think I'd rather just do it from SSH. ...Thanks again Dave.

-Jeremy
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add service in windows ajkannan83 General 3 09-12-2005 01:36 PM
Add service in windows ajkannan83 Linux - Software 2 09-12-2005 09:32 AM
Add service in windows ajkannan83 General 2 09-12-2005 03:14 AM
MySQL ODBC driver fails when trying to add a DSN to MySQL banjoman Linux - Software 0 01-24-2005 09:59 AM
Cant add MySQL through add/remove programs Hero Doug Fedora 6 01-03-2004 10:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration