PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Mysql startet nicht über das Startscript



daN-the-man
19.05.07, 12:13
Hi ihr!

Ich hab da nen Problem, bei dem ich echt nicht mehr weiter weiß. Die Situation ist folgende:
Ich habe einen Server, auf dem ich nen Mysqlserver am Laufen habe. Das Problem ist jetzt, dass beim Systemstart der mysqld-Prozess nicht mitgestartet wird. Auch wenn ich versuche, den Server über /etc/init.d/mysql start zu starten, bekomme ich folgende Fehlermeldung:

Updating MySQL privilege database...
/usr/bin/mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) when trying to connect
Error executing '/usr/bin/mysqlcheck --defaults-extra-file=/var/lib/mysql/mysql_upgrade_defaults --check-upgrade --all-databases --auto-repair --user=root'
failed


Was mich zunächst wundert, ist das --user=root . Ich habe in der my.cnf überall user=mysql eingetragen und auch das socket-File ist dem user mysql zugeordnet.

Starten lässt sich der Server nur, indem ich mysqld_safe --user=mysql & eingebe.

Hat einer ne Idee, woran das liegen könnte?

Edit: Noch ein paar Zusatzinformationen:

Es ist ein Mysql 5.0.33

Die my.cnf (user und gruppe sind mysql) sieht so aus:


# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
user=mysql
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
# log-bin=mysql-bin

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
# where you replace <host>, <user>, <password> by quoted strings and
# <port> by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host = <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port = <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Point the following paths to different dedicated disks
#tmpdir = /tmp/
#log-update = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

# The safe_mysqld script
[safe_mysqld]
err-log=/var/lib/mysql/mysqld.log

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
user=mysql

[mysql.server]
user=mysql


Meine Vermutung ist es ja irgendwie, dass durch den Aufruf des Scriptes das ganze nicht mehr als "mysql" user ausgeführt wird. Doch ich habe auch keine Ahnung wie ich das ändern könnte, da in der cnf ja auch überall mysql als user angegeben ist.

drcux
19.05.07, 15:05
$editor /etc/init.d/mysql

daN-the-man
25.05.07, 17:03
Wüsste jetzt leider nicht, was ich hier noch editieren sollte :(

So sieht es aus:


#!/bin/bash
# Copyright (c) 1995-2002 SuSE Linux AG Nuernberg, Germany.
#
# Author: Lenz Grimmer <feedback@suse.de>
#
# /etc/init.d/mysql
#
# and its symbolic link
#
# /usr/sbin/rcmysql
#
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $network $remote_fs
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop:
# Description: Start the MySQL database server
### END INIT INFO

# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.

# Test, if mysqld or mysql-max actually exist
unset MYSQLD
# use mysqld-debug only if explicitly requested (TODO: sysconfig variable?)
if test "$MYSQLD_DEBUG" = yes -a -x /usr/sbin/mysqld-debug
then
MYSQLD=/usr/sbin/mysqld-debug
elif test -x /usr/sbin/mysqld-max
then
MYSQLD=/usr/sbin/mysqld-max
elif test -x /usr/sbin/mysqld
then
MYSQLD=/usr/sbin/mysqld
fi
test "$MYSQLD" || {
echo "Nor /usr/sbin/mysqld nor /usr/sbin/mysqld-max exists";
rc_failed 5; rc_status -v; rc_exit;
}

# The following section has been taken from
# the original MySQL init script
basedir=/usr
datadir=/var/lib/mysql
mysql_daemon_user=mysql
mysql_daemon_group=mysql
pid_file=/var/lib/mysql/mysqld.pid
socket=/var/lib/mysql/mysql.sock
print_defaults=/usr/bin/my_print_defaults
export TMPDIR=/var/lib/mysql/.tmp

mode=$1 # start or stop

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

wait_for_socket()
{
local i
for((i=0; i<50; i++)); do
sleep 0.2
test -S $1 && i='' && break
done
test -z "$i" || return 1
return 0
}

# Don't run killproc -TERM, as it could send a SIGKILL as well, possibly
# resulting in database corruption. Run kill -TERM manually instead, wait
# approximately 60 seconds and fail if mysql doesn't respond. This will at
# least prevent the SIGKILL when doing 'rcmysql stop' manually. During system
# shutdown, we are out of luck...
# See https://bugzilla.novell.com/show_bug.cgi?id=223209
kill_mysql ()
{
local pid exe
test -e "$pid_file" || return 7 # not running
pid=`cat "$pid_file"` || return 4 # insufficient privileges
if ! test -e /proc/version; then
mount -n -t proc proc /proc
test -e /proc/version || return 100
fi
test -L "/proc/$pid/exe" || return 7
exe=`readlink "/proc/$pid/exe"` || return 4
test "$exe" = "$MYSQLD" || return 7
kill -STOP "$pid"
kill -TERM "$pid" || return 4 # suboptimal
kill -CONT "$pid"
for i in `seq 600`; do
# mysqld removes its pid file
test -e "$pid_file" || return 0
LC_ALL=C sleep 0.1
done
test -e "$pid_file" || return 0
return 1
}

parse_arguments `$print_defaults $defaults mysqld mysql_server`

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

case "$1" in
start)
# exit gracefully, if we are already running
checkproc $MYSQLD && echo -n "Starting service MySQL " && \
rc_status -v && rc_exit

# Test, if safe_mysqld actually exists
SAFE_MYSQLD=/usr/bin/mysqld_safe
test -x $SAFE_MYSQLD || {
echo "$SAFE_MYSQLD does not exist ";
rc_failed 5; rc_status -v; rc_exit;
}
debug_flags=""
if test "$MYSQLD_DEBUG" = yes; then
# add --log, --core-file and --debug
# but only if not already set in my.cnf
if ! $print_defaults mysqld | \
grep -q -e '--log$' -e '--log[[:blank:]=]'
then
debug_flags="--log=$datadir/mysqld-query.log"
fi
if ! $print_defaults mysqld | grep -q -e '^--debug\>' &&
test "$MYSQLD" = /usr/sbin/mysqld-debug
then
debug_flags="$debug_flags --debug=d:t:F:L:o,$datadir/mysqld.trace"
fi
if ! $print_defaults mysqld | grep -q -e '^--core-file\>'
then
debug_flags="$debug_flags --core-file"
fi
fi

# check for ISAM tables
tables=`find $datadir -name '*.ISM' | sed "s@$datadir/*@@; s@.ISM@@; s@/@.@;"`
if test "$tables" ; then
echo
echo "Some tables still use ISAM format, which is NO LONGER SUPPORTED"
echo "since mysql 5.0. To use these tables, you would need to open them"
echo "from an older mysql server and convert to something better (eg. MyISAM)."
echo
echo "Tables using ISAM are: "
echo " $tables "
echo
fi
# check for bdb tables
tables=`find $datadir -name '*.db' | sed "s@$datadir/*@@; s@.db@@; s@/@.@;"`
if test -n "$tables" ; then
echo
echo "Some tables still use BerkeleyDB format, please convert them to something "
echo "else. BerkeleyDB support will be dropped in future releases. "
echo "You can use mysql_convert_table_format script to do this conversion. "
echo
echo "Tables using BerkeleyDB are: "
echo " $tables "
echo
fi

# We assume a fresh install if the directory $datadir/mysql
# does not exist and create the privilege database
if ! test -d $datadir/mysql; then
echo "Creating MySQL privilege database... "
mysql_install_db --user=$mysql_daemon_user --datadir=$datadir ||{
rc_failed; rc_status -v; rc_exit
}
fi
# Run mysql_upgrade on every package install/upgrade. Not allways
# necessary, but doesn't do any harm.
if test -f $datadir/.run-mysql_upgrade ; then
echo "Updating MySQL privilege database... "
# instead of running mysqld --bootstrap, which wouldn't allow
# us to run mysql_upgrade, we start a full-featured server with
# --skip-grant-tables and restict access to it by unix
# permissions of the named socket
protected=$datadir/.protected
chown $mysql_daemon_user:$mysql_daemon_group $protected
chmod 700 $protected
$SAFE_MYSQLD \
--mysqld=${MYSQLD#/usr/sbin/} \
$debug_flags \
--skip-grant-tables \
--skip-networking \
--user=$mysql_daemon_user \
--pid-file=$protected/mysqld.pid \
--socket=$protected/mysql.sock \
--group=$mysql_daemon_group &>/dev/null &
wait_for_socket $protected/mysql.sock || {
rc_failed; rc_status -v; rc_exit;
}
/usr/bin/mysql_upgrade \
--basedir=$basedir \
--socket=$protected/mysql.sock || {
rc_failed; rc_status -v;
killproc -p $protected/mysqld.pid -TERM $MYSQLD
rc_exit;
}
killproc -p $protected/mysqld.pid -TERM $MYSQLD
# Fix ownerships and permissions for $datadir
chmod 755 $datadir
chown -R $mysql_daemon_user:$mysql_daemon_group $datadir
rm -f $datadir/.run-mysql_upgrade \
$datadir/{update-stamp-*,mysql/stamp-4.1} # used in the past
if test -f $datadir/mysql/stamp-4.1 ; then
rm $datadir/mysql/stamp-4.1
fi

fi

echo -n "Starting service MySQL "

$SAFE_MYSQLD \
--mysqld=${MYSQLD#/usr/sbin/} \
$debug_flags \
--user=$mysql_daemon_user \
--pid-file=$pid_file \
--socket=$socket \
--datadir=$datadir &>/dev/null &

wait_for_socket $socket || {
rc_failed; rc_status -v; rc_exit;
}

# Rmember status and be verbose
rc_status -v
;;

stop)
echo -n "Shutting down service MySQL "
kill_mysql

# Remember status and be verbose
rc_status -v
;;

try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
$0 status >/dev/null && $0 restart

# Remember status and be quiet
rc_status
;;

restart|force-reload)
echo "Restarting service MySQL "
$0 stop
$0 start

rc_status
;;

reload)
echo -n "Reloading service MySQL "
killproc -p $pid_file -HUP $MYSQLD
touch $pid_file
rc_status -v
;;

check|status)
echo -n "Checking for service MySQL: "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.

# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running

# NOTE: checkproc returns LSB compliant status values.
checkproc $MYSQLD
rc_status -v
;;

*)
echo "Usage: $0 {start|stop|status|reload|restart|try-restart|force-reload}"
exit 1
;;
esac
rc_exit

# vim: ft=sh

Immerhin stehen "mysql_daemon_user" und "mysql_daemon_group" ja schon auf mysql!

Ich bin echt nen bisschen am verzweifeln. Noch einer ne idee?