LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-04-2006, 06:29 PM   #1
Berticus
Member
 
Registered: Jul 2005
Distribution: Arch
Posts: 159

Rep: Reputation: 31
mysql autostart


I installed mysql-standard-4.0.25-pc-linux-gnu-i686 in /usr/local and made a system link of mysql. It can start up when I run this command as root:
Code:
/usr/local/mysql/bin/mysqld_safe --user=mysql &
In zenwalk, all I need to do in order to get a service to autostart is put a script in /etc/rc.d. This is the script I am using:
Code:
#!/bin/sh
# Start mysqld:
mysqld_start() {
  if [ -x /usr/local/mysql/bin/mysqld_safe ]; then
    # If there is an old PID file (no mysqld running), clean it up:
    if [ -r /var/run/mysql/mysql.pid ]; then
      if ! ps axc | grep mysqld 1> /dev/null 2> /dev/null ; then
        echo "Cleaning up old /var/run/mysql/mysql.pid."
        rm -f /var/run/mysql/mysql.pid
      fi
    fi
    /usr/local/mysql/bin/mysqld_safe --user=mysql
    --datadir=/var/run/mysql --pid-file=/var/run/mysql/mysql.pid
    --socket=/var/run/mysql/mysql.sock &
  fi
}

# Stop mysqld:
mysqld_stop() {
  # If there is no PID file, ignore this request...
  if [ -r /var/run/mysql/mysql.pid ]; then
    killall mysqld
    # Wait at least one minute for it to exit, as we don't know how big the DB is...
    for second in 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 \
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 60 ; do
      if [ ! -r /usr/local/mysql/mysql.pid ]; then
        break;
      fi
      sleep 1
    done
    if [ "$second" = "60" ]; then
      echo "WARNING:  Gave up waiting for mysqld to exit!"
      sleep 15
    fi
  fi
}

# Restart mysqld:
mysqld_restart() {
  mysqld_stop
  mysqld_start
}

case "$1" in
'start')
  mysqld_start
  ;;
'stop')
  mysqld_stop
  ;;
'restart')
  mysqld_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac
It's not that it doesn't work at all, it just all it does is it hangs there after I do:
Code:
/etc/rc.d/rc.mysqld start
No matter how many times I hit enter it won't return me. However, after I do Ctrl+Z, and I use mysqladmin to ping the server, it says mysqld is alive.

What am I doing wrong in that script?
 
Old 03-04-2006, 07:54 PM   #2
burntfuse
Member
 
Registered: Sep 2005
Location: Laurel, MD, USA
Distribution: Slackware 10.1, FC5
Posts: 164

Rep: Reputation: 30
"/usr/local/mysql/bin/mysqld_safe --user=mysql" should be "/usr/local/mysql/bin/mysqld_safe --user=mysql &". The way you wrote it, mysqld will be in the foreground, so nothing else will run until it exits, but the "&" will put it in the background. Please correct me if I'm wrong...
 
Old 03-04-2006, 08:47 PM   #3
Berticus
Member
 
Registered: Jul 2005
Distribution: Arch
Posts: 159

Original Poster
Rep: Reputation: 31
I figured out a way to fix it.

Thanks anyway.
 
Old 03-05-2006, 12:33 PM   #4
Berticus
Member
 
Registered: Jul 2005
Distribution: Arch
Posts: 159

Original Poster
Rep: Reputation: 31
Okay, doesn't seem to work anymore... Last time I just rebooted and it was fine. Then I shutdown, slept for 5 or so hours, woke up and turned it on, and it didn't start.

Now when i start it manually, it hangs at the same exact spot.

BTW, I'm using zenwalk (minslax), derived from Slackware.
 
  


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. NoviceW Linux - Networking 17 09-17-2014 02:13 PM
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock welery Linux - Software 19 03-06-2014 07:19 AM
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
Problems with MySQL on SuSE: Can't Connect (/var/lib/mysql/mysql.sock) neocookie Linux - Software 8 02-07-2008 11:48 PM
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

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

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