LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-10-2006, 05:40 PM   #1
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Rep: Reputation: 15
mysql.server startup script is not cooperating.


After creating a copy of mysql.server in my /etc/init.d directory and the appropriate symbolic links in /etc/rc*.d, MySQL will not run on startup. As a matter of fact, executing the script from the shell doesn't work either. It outputs

Code:
Starting MySQL.................................. *
This command:

Code:
$ sudo mysqld_safe --user=mysql
gets the server up and running with no problems. Any ideas?
 
Old 04-10-2006, 05:44 PM   #2
ftenario
Member
 
Registered: Jul 2003
Location: Camarillo, CA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
Check the log file for some errors. It may give you a clue.
 
Old 04-10-2006, 05:56 PM   #3
halitayarci
LQ Newbie
 
Registered: Nov 2004
Location: Istanbul
Distribution: Slackware 10.2
Posts: 19

Rep: Reputation: 0
try this command
Quote:
chmod 755 /etc/rc.d/rc.mysqld
 
Old 04-10-2006, 06:05 PM   #4
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ftenario
Check the log file for some errors. It may give you a clue.
Which log file are you referring to?

Quote:
Originally Posted by halitayarci
try this command
In my particular distribution, my /etc/rc.d is divided up by runlevels, as in rc0.d, rc1.d, ..., rc6.d. There is no single rc.d directory.
 
Old 04-10-2006, 07:25 PM   #5
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
You will find that all those rc#.d files have nothing in them but links. Probably you want to look in /etc/rc.d/init.d for the real startup scripts.
 
Old 04-10-2006, 07:32 PM   #6
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jiml8
You will find that all those rc#.d files have nothing in them but links. Probably you want to look in /etc/rc.d/init.d for the real startup scripts.
I've already added the appropriate links to the rc*.d directories (in this case, rc0.d and rc3.d) and linked them to where my real script resides: /etc/init.d/mysql.server.

Last edited by vmlinuz.gz; 04-10-2006 at 07:39 PM.
 
Old 04-11-2006, 11:51 AM   #7
ftenario
Member
 
Registered: Jul 2003
Location: Camarillo, CA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
The log file is usually in the data directory. It's called <hostname>.err
 
Old 04-11-2006, 12:40 PM   #8
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Well, it seems mysql.server cannot even access the server. After running the script, <hostname>.err doesn't show anything new happening, not even a connection attempt.
 
Old 04-11-2006, 02:12 PM   #9
ftenario
Member
 
Registered: Jul 2003
Location: Camarillo, CA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
Have you taken a look inside your mysql.server script? Try to find the "basedir" and "datadir" variables and verify that it it points to mysql in your system.

In my system, basedir=/usr/local/mysql/
It may vary in your system. Did u install mysql from source? If you did it from source, basedir is equal to your "--prefix=<path_to_your_mysql>" when you do the configure.

Or you can go to your mysql folder and run mysqld_safe from there to verify that it works.

Hope this helps
 
Old 04-13-2006, 12:20 PM   #10
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Initially, basedir= and datadir= were blank. Appending `/usr/local/mysql' and `/usr/local/mysql/data' didn't help. I verified that those were the correct directories, and they were. Running mysql.server while the system is up still won't work, but any other method of starting the MySQL server will. I used the binaries for the MySQL website.

Last edited by vmlinuz.gz; 04-13-2006 at 12:21 PM.
 
Old 04-13-2006, 12:45 PM   #11
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
hmm. I tried starting up apache at boot time with no luck either. Perhaps I am doing something wrong. Here's what I've been doing.

1. Place the script (or a symbolic link to it) in /etc/init.d.
2. Place symbolic link to the script/link in /etc/init.d from /etc/rc0.d and /etc/rc3.d. I named them K01xxx in rc0.d and S99xxx in rc3.d.

Maybe this will help in determing the problem.
 
Old 04-13-2006, 01:02 PM   #12
ftenario
Member
 
Registered: Jul 2003
Location: Camarillo, CA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
The real scripts are in /etc/init.d/
The symbolic links (SXXxxxx) are in /etc/rc3.d assuming that you run in runlevel 3. If you run the GUI (kde or gnome), then the symbolic links should be in /etc/rc5.d

When troubleshooting like this, I always start by making the server work by hand first and not go to runlevel runs.

If you can run it manually, theres better chances of running automatically.
 
Old 04-14-2006, 11:30 AM   #13
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
Right. I think a more logical way to go would be to determine what's wrong with the script, and then see how to get it started. I will post my mysql.server script. Maybe that will give so clues as to where the problem is originating.

Code:
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind

# MySQL daemon start/stop script.

# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: A very fast and reliable SQL database engine.

# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO
 
# If you install MySQL on some other places than /usr/local/mysql, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
#   [mysqld]
#   basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
#   below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

# The following variables are only set for letting mysql.server find things.

# Set some defaults
pid_file=
server_pid_file=
use_mysqld_safe=1
user=mysql
if test -z "$basedir"
then
  basedir=/usr/local/mysql
  bindir=./bin
  if test -z "$datadir"
  then
    datadir=/usr/local/mysql/data
  fi
  sbindir=./bin
  libexecdir=./bin
else
  bindir="$basedir/bin"
  if test -z "$datadir"
  then
    datadir="$basedir/data"
  fi
  sbindir="$basedir/sbin"
  libexecdir="$basedir/libexec"
fi

#
# Use LSB init script functions for printing messages, if possible
#
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
  source $lsb_functions
else
  log_success_msg()
  {
    echo " SUCCESS! $@"
  }
  log_failure_msg()
  {
    echo " ERROR! $@"
  }
fi

PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
export PATH

mode=$1    # start or stop

case `echo "testing\c"`,`echo -n testing` in
    *c*,-n*) echo_n=   echo_c=     ;;
    *c*,*)   echo_n=-n echo_c=     ;;
    *)       echo_n=   echo_c='\c' ;;
esac

parse_server_arguments() {
  for arg do
    case "$arg" in
      --basedir=*)  basedir=`echo "$arg" | sed -e 's/^[^=]*=//'`
                    bindir="$basedir/bin"
		    datadir="$basedir/data"
		    sbindir="$basedir/sbin"
		    libexecdir="$basedir/libexec"
        ;;
      --datadir=*)  datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --user=*)  user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --use-mysqld_safe) use_mysqld_safe=1;;
      --use-manager)     use_mysqld_safe=0;;
    esac
  done
}

parse_manager_arguments() {
  for arg do
    case "$arg" in
      --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --user=*)  user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
    esac
  done
}

wait_for_pid () {
  i=0
  while test $i -lt 35 ; do
    sleep 1
    case "$1" in
      'created')
        test -s $pid_file && i='' && break
        ;;
      'removed')
        test ! -s $pid_file && i='' && break
        ;;
      *)
        echo "wait_for_pid () usage: wait_for_pid created|removed"
        exit 1
        ;;
    esac
    echo $echo_n ".$echo_c"
    i=`expr $i + 1`
  done

  if test -z "$i" ; then
    log_success_msg
  else
    log_failure_msg
  fi
}

# Get arguments from the my.cnf file,
# the only group, which is read from now on is [mysqld]
if test -x ./bin/my_print_defaults
then
  print_defaults="./bin/my_print_defaults"
elif test -x $bindir/my_print_defaults
then
  print_defaults="$bindir/my_print_defaults"
elif test -x $bindir/mysql_print_defaults
then
  print_defaults="$bindir/mysql_print_defaults"
else
  # Try to find basedir in /etc/my.cnf
  conf=/etc/my.cnf
  print_defaults=
  if test -r $conf
  then
    subpat='^[^=]*basedir[^=]*=\(.*\)$'
    dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
    for d in $dirs
    do
      d=`echo $d | sed -e 's/[ 	]//g'`
      if test -x "$d/bin/my_print_defaults"
      then
        print_defaults="$d/bin/my_print_defaults"
        break
      fi
      if test -x "$d/bin/mysql_print_defaults"
      then
        print_defaults="$d/bin/mysql_print_defaults"
        break
      fi
    done
  fi

  # Hope it's in the PATH ... but I doubt it
  test -z "$print_defaults" && print_defaults="my_print_defaults"
fi

#
# Read defaults file from 'basedir'.   If there is no defaults file there
# check if it's in the old (depricated) place (datadir) and read it from there
#

extra_args=""
if test -r "$basedir/my.cnf"
then
  extra_args="-e $basedir/my.cnf"
else
  if test -r "$datadir/my.cnf"
  then
    extra_args="-e $datadir/my.cnf"
  fi
fi

parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`

# Look for the pidfile 
parse_manager_arguments `$print_defaults $extra_args manager`

#
# Set pid file if not given
#
if test -z "$pid_file"
then
  pid_file=$datadir/mysqlmanager-`/bin/hostname`.pid
else
  case "$pid_file" in
    /* ) ;;
    * )  pid_file="$datadir/$pid_file" ;;
  esac
fi
if test -z "$server_pid_file"
then
  server_pid_file=$datadir/`/bin/hostname`.pid
else
  case "$server_pid_file" in
    /* ) ;;
    * )  server_pid_file="$datadir/$server_pid_file" ;;
  esac
fi

# Safeguard (relative paths, core dumps..)
cd $basedir

case "$mode" in
  'start')
    # Start daemon

    manager=$bindir/mysqlmanager
    if test -x $libexecdir/mysqlmanager
    then
      manager=$libexecdir/mysqlmanager
    elif test -x $sbindir/mysqlmanager
    then
      manager=$sbindir/mysqlmanager
    fi

    echo $echo_n "Starting MySQL"
    if test -x $manager -a "$use_mysqld_safe" = "0"
    then
      # Give extra arguments to mysqld with the my.cnf file. This script may
      # be overwritten at next upgrade.
      $manager --user=$user --pid-file=$pid_file >/dev/null 2>&1 &
      wait_for_pid created

      # Make lock for RedHat / SuSE
      if test -w /var/lock/subsys
      then
        touch /var/lock/subsys/mysqlmanager
      fi
    elif test -x $bindir/mysqld_safe
    then
      # Give extra arguments to mysqld with the my.cnf file. This script
      # may be overwritten at next upgrade.
      pid_file=$server_pid_file
      $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file >/dev/null 2>&1 &
      wait_for_pid created

      # Make lock for RedHat / SuSE
      if test -w /var/lock/subsys
      then
        touch /var/lock/subsys/mysql
      fi
    else
      log_failure_msg "Couldn't find MySQL manager or server"
    fi
    ;;

  'stop')
    # Stop daemon. We use a signal here to avoid having to know the
    # root password.

    # The RedHat / SuSE lock directory to remove
    lock_dir=/var/lock/subsys/mysqlmanager

    # If the manager pid_file doesn't exist, try the server's
    if test ! -s "$pid_file"
    then
      pid_file=$server_pid_file
      lock_dir=/var/lock/subsys/mysql
    fi

    if test -s "$pid_file"
    then
      mysqlmanager_pid=`cat $pid_file`
      echo $echo_n "Shutting down MySQL"
      kill $mysqlmanager_pid
      # mysqlmanager should remove the pid_file when it exits, so wait for it.
      wait_for_pid removed

      # delete lock for RedHat / SuSE
      if test -f $lock_dir
      then
        rm -f $lock_dir
      fi
    else
      log_failure_msg "MySQL manager or server PID file could not be found!"
    fi
    ;;

  'restart')
    # Stop the service and regardless of whether it was
    # running or not, start it again.
    $0 stop
    $0 start
    ;;

  'reload')
    if test -s "$server_pid_file" ; then
      mysqld_pid=`cat $server_pid_file`
      kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
      touch $server_pid_file
    else
      log_failure_msg "MySQL PID file could not be found!"
    fi
    ;;

  *)
    # usage
    echo "Usage: $0 start|stop|restart|reload"
    exit 1
    ;;
esac
The instructions say that it should be put in rc3.d; but I will try rc5.d after I get it working if you believe that would help.
 
Old 04-14-2006, 11:49 AM   #14
ftenario
Member
 
Registered: Jul 2003
Location: Camarillo, CA
Distribution: Debian
Posts: 48

Rep: Reputation: 15
I'm out of ideas.

Probably a few more steps:
run mysql from /usr/local/mysql/bin/mysqld_safe
See if it runs. If it does, then more likely it's you mysql.server script. How about the permission of mysql.server? It should be executable.

Check the owner of your mysql installation folder and the rest below it. It should be own by mysql user and mysql group

You must also have these tables /usr/local/mysql/data/mysql/<tables> where <tables> are mysql system tables
 
Old 04-14-2006, 09:41 PM   #15
vmlinuz.gz
Member
 
Registered: Nov 2005
Posts: 123

Original Poster
Rep: Reputation: 15
We are making progress. Mysql.server was originally owned by root. It will now run, but only if I'm logged in as the mysql user.

EDIT: Actually, mysql.server will run (only as the `mysql' user) regardless of permissions; i.e. I changed the owner/group to my personal user account and it still ran when I was logged in as mysql.

EDIT2: The following command:

Code:
$ sudo ./mysql.server start --user=mysql
works as well. It seems, then, that our objective would be to get the script to run as mysql.

EDIT3: Moving the symbolic link from rc3.d to rc5.d did not make a difference.

Last edited by vmlinuz.gz; 04-14-2006 at 10:23 PM.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 01:52 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
MySQL server dies immediately upon startup... CrazyPilot Linux - Software 2 03-22-2005 07:14 PM
problem with mysql startup script on server BeetleBailey Programming 2 07-22-2004 04:37 PM
Apache server and MySQL server won't run at startup! dday007 Linux - General 2 02-07-2003 02:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:05 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