Team LiB
Previous Section Next Section


mysqld_safe is a shell script that starts the mysqld server and monitors it. If the server dies, mysqld_safe restarts it. If there is a server named mysqld-max, mysqld_safe starts it rather than mysqld.

mysqld_safe is a shell script and is unavailable on Windows. There is also a compiled version that can be used on NetWare.

Prior to MySQL 4, mysqld_safe was known as safe_mysqld. See "Upgrading Tips" later in this section.


mysqld_safe [options]

Options Specific to mysqld_safe

Options that may be used with mysqld may also be used with mysqld_safe, which simply passes them to mysqld. In addition, mysqld_safe understands the following options of its own:

  • --basedir=dir_name

    The pathname to the MySQL base directory.

  • --core-file-size=n

    Limit the size of core files to n bytes if the server crashes.

  • --datadir=dir_name

    The pathname to the MySQL data directory.

  • --err-log=file_name

    This is the old form of the --log-error option.

  • --ledir=dir_name

    Look for the server in this directory. (It's taken to be the location of the "libexec" directory.)

  • --log-error=file_name

    Use this file for the error log. Relative names are interpreted with respect to the directory from which mysqld_safe was invoked. If this option is not specified, the default error log is HOSTNAME.err in the data directory, where HOSTNAME is the name of the current host.

  • --mysqld=file_name

    Use file_name as the path to the mysqld program.

  • --mysqld-version=suffix

    The value of this option is a suffix string. If the option is given, the suffix is added to the basename mysqld, with a dash in between, to produce the name of the server that mysqld_safe should start.

  • --open-files=n, --open-files-limit=n

    Set to n the number of file descriptors that should be made available to mysqld.

  • --pid-file=file_name

    Set the name of the mysqld process ID file.

  • --port=port_num

    The port number on which the server should listen for TCP/IP connections.

  • --skip-kill-mysqld

    Do not try to kill any currently running mysqld process before starting a new one. This can be useful if you are running multiple instances of a given mysqld binary. If is effective only on Linux.

  • --socket=file_name

    The pathname of the Unix socket file.

  • --timezone=tz_name

    Set the time zone to tz_name. This might be useful if the server doesn't determine the system time zone automatically.

  • --user=user_name, --user=uid

    The username or numeric user ID of the account to use for running the server.

Upgrading Tips

If you're upgrading to MySQL 4.x from MySQL 3.x, when mysqld_safe was known as safe_mysqld, watch out for the following issues:

  • You should modify any startup scripts that invoke safe_mysqld so that they invoke mysqld_safe instead. The mysql.server script is one example. However, if you replace your older version with a 4.x version, that will update it automatically to invoke mysqld_safe. If you're using your own startup scripts, make the necessary adjustments.

  • You should rename [safe_mysqld] groups in option files to [mysqld_safe].

    Team LiB
    Previous Section Next Section