MySQL Reference Manual for version 4.0.18.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.3 mysqld_safe, The Wrapper Around mysqld

mysqld_safe is the recommended way to start a mysqld server 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.

On Linux, the MySQL-Max RPM uses this mysqld_safe feature. (It just installs the mysqld-max executable, so mysqld_safe automatically uses this executable when mysqld_safe is restarted.)

The preference of mysqld_safe for mysqld-max over mysqld makes it very easy to test a new mysqld binary in an existing installation. Just run configure with the options you want and then install the new mysqld binary as mysqld-max in the same directory where your existing mysqld binary is located.

On the other hand, this behavior means that if you install a MySQL-Max distribution that includes a server named mysqld-max, then upgrade later to a non-Max version of MySQL, mysqld_safe will still attempt to run the old mysqld-max server. If you perform such an upgrade, manually remove the old mysqld-max server to ensure that mysqld_safe runs the new mysqld server.

Normally, you should never edit the mysqld_safe script. Instead, put the options to mysqld_safe in the [mysqld_safe] section in a `my.cnf' option file. See section 4.3.2 Using Option Files. 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, though you should rename such sections to [mysqld_safe] once you begin using MySQL 4.0 or later.)

Note that all options specified to mysqld_safe on the command-line are passed to mysqld. If you wants to use any options for mysqld_safe that mysqld doesn't support, you must specify them in the option file.

Many of the options to mysqld_safe are the same as the options to mysqld. See section 5.2.1 mysqld Command-line Options.

mysqld_safe supports the following options:

--basedir=path
The path to the installation directory.
--core-file-size=#
The size of the core file mysqld should be able to create. Passed to ulimit -c.
--datadir=path
The path to the data directory.
--defaults-extra-file=path
The name of an option file to be read in addition to the usual option files.
--defaults-file=path
The name of an option file to be read instead of the usual option files.
--err-log=path
Old form of the --log-error option, to be used before MySQL 4.0.
--log-error=path
Write the error log to the above file. See section 5.8.1 The Error Log.
--ledir=path
The path to the directory containing the mysqld program. Use this option to explicitly indicate the location of the server.
--log=path
--mysqld=prog_name
The name of the server program (in the ledir directory) that you want to start.
--mysqld-version=suffix
Similar to --mysqld= but here you only give the suffix for the server program name. The base name is assumed to be mysqld. For example, if you use --mysqld-version=max, mysqld_safe will start the mysqld-max program in the ledir directory. If the argument to --mysqld-version is empty, mysqld in the ledir directory is used.
--nice=#
Use the nice program to set the server's scheduling priority to the given value. This option was added in MySQL 4.0.14.
--no-defaults
Do not read any option files.
--open-files-limit=#
The number of files 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
The path to the process ID file.
--port=#
The TCP/IP port number.
--socket=path
The Unix socket file path.
--timezone=#
Set the time zone (the 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 distribution of MySQL, even those these normally install the server in slightly different locations. See section 2.1.5 Installation Layouts. mysqld_safe expects one of the following conditions to be true: