mysqld_safe
, The Wrapper Around mysqld
mysqld_safe
is the recommended way to start a mysqld
daemon on Unix. mysqld_safe
adds some safety features such as
restarting the server when an error occurs and logging run-time
information to a log file.
Note:
Before MySQL 4.0, mysqld_safe
is named safe_mysqld
.
To preserve backward compatibility, MySQL binary distributions for
some time will include safe_mysqld
as a symbolic link to
mysqld_safe
.
If you don't use --mysqld=#
or --mysqld-version=#
mysqld_safe
will use an executable named mysqld-max
if it
exists. If not, mysqld_safe
will start mysqld
.
This makes it very easy to test to use mysqld-max
instead of
mysqld
; just copy mysqld-max
to where you have
mysqld
and it will be used.
Normally one should never edit the mysqld_safe
script, but
instead put the options to mysqld_safe
in the
[mysqld_safe]
section in the `my.cnf'
file. mysqld_safe
reads all options from the [mysqld]
,
[server]
and [mysqld_safe]
sections from the option files.
(For backward compatibility, it also reads the
[safe_mysqld]
sections.)
See section 4.1.2 `my.cnf' Option Files.
Note that all options on the command-line to mysqld_safe
are passed
to mysqld
. If you wants to use any options in mysqld_safe
that
mysqld
doesn't support, you must specify these in the option file.
Most of the options to mysqld_safe
are the same as the options to
mysqld
. See section 4.1.1 mysqld
Command-line Options.
mysqld_safe
supports the following options:
--basedir=path
--core-file-size=#
mysqld
should be able to create. Passed to ulimit -c
.
--datadir=path
--defaults-extra-file=path
--defaults-file=path
--err-log=path (this is marked obsolete in 4.0; Use --log-error instead)
--log-error=path
--ledir=path
mysqld
--log=path
--mysqld=mysqld-version
mysqld
version in the ledir
directory you want to start.
--mysqld-version=version
--mysqld=
but here you only give the suffix for mysqld
.
For example if you use --mysqld-version=max
, mysqld_safe
will
start the ledir/mysqld-max
version. If the argument to
--mysqld-version
is empty, ledir/mysqld
will be used.
--nice=# (added in MySQL 4.0.14)
--no-defaults
--open-files-limit=#
mysqld
should be able to open. Passed to ulimit -n
. Note that you need to start mysqld_safe
as root
for this to work properly!
--pid-file=path
--port=#
--socket=path
--timezone=#
TZ
) variable to the value of this parameter.
--user=#
The mysqld_safe
script is written so that it normally is able to start
a server that was installed from either a source or a binary version of
MySQL, even if these install the server in slightly different
locations. mysqld_safe
expects one of these conditions to be true:
mysqld_safe
is invoked. mysqld_safe
looks under its working
directory for `bin' and `data' directories (for binary
distributions) or for `libexec' and `var' directories (for source
distributions). This condition should be met if you execute
mysqld_safe
from your MySQL installation directory (for
example, `/usr/local/mysql' for a binary distribution).
mysqld_safe
attempts to locate them by absolute pathnames. Typical
locations are `/usr/local/libexec' and `/usr/local/var'.
The actual locations are determined when the distribution was built from which
mysqld_safe
comes. They should be correct if
MySQL was installed in a standard location.
Because mysqld_safe
will try to find the server and databases relative
to its own working directory, you can install a binary distribution of
MySQL anywhere, as long as you start mysqld_safe
from the
MySQL installation directory:
shell> cd mysql_installation_directory shell> bin/mysqld_safe &
If mysqld_safe
fails, even when invoked from the MySQL
installation directory, you can modify it to use the path to mysqld
and the pathname options that are correct for your system. Note that if you
upgrade MySQL in the future, your modified version of
mysqld_safe
will be overwritten, so you should make a copy of your
edited version that you can reinstall.