Differences between mysqld and mysqld_safe

Source: Internet
Author: User

Article 1:

It is rare to run the mysqld program directly to start the MySQL service. The mysqld_safe script will continue to monitor its running status after the MySQL server is started and restart it when it crashes. Using the mysqld_safe script to start a MySQL server is very common in bsd unix systems, and MySQL in non-bsd unix systems. the server script also calls the mysqld_safe script to start the MySQL server. It usually does the following:
1. Check the system and options.
2. Check the MyISAM table.
3. Keep the MySQL server window.
4. Start and monitor mysqld. Restart if it is terminated due to an error.
5. Send the error message of mysqld to the host_name.err file in the data directory.
6. Send the screen output of mysqld_safe to the host_name.safe file in the data directory.

From: http://yunwei.blog.51cto.com/381136/421031

Article 2:

Mysqld_safe
Mysqld_safe is recommended in UNIX and Netware to start the mysqld server. Mysqld_safe adds some security features, such as restarting the server when an error occurs and writing runtime information to the error log file. This section describes the specific actions of Netware.
Note: To maintain backward compatibility with the old version of MySQL, the binary distribution of MySQL still includes safe_mysqld as the symbolic link of mysqld_safe. However, you should not rely on it any more, because it will be deleted in the future.
By default, mysqld_safe tries to start and execute mysqld-max (if any). Otherwise, mysqld is started. The meaning of this behavior is:
· In Linux, MySQL-max RPM depends on the behavior of mysqld_safe. You can run mysqld-Max during RPM installation to enable mysqld_safe to automatically use executable commands from this point.
· If you install the mysql-Max distribution version that includes the mysqld-Max server and upgrade it to a non-Max MySQL version later, mysqld_safe still tries to run the old mysqld-Max server. During the upgrade, You Should manually delete the old mysqld-Max server to ensure that mysqld_safe runs the new mysqld server.
To bypass the default behavior and explicitly specify the server you want to run, specify -- mysqld or -- mysqld-version for mysqld_safe.
Mysqld_safe reads all options from the [mysqld], [server], and [mysqld_safe] sections of the Option file. To ensure backward compatibility, it also reads the [safe_mysqld] section, although you should rename this Part as [mysqld_safe] During MySQL 5.1 installation.
Mysqld_safe supports the following options:
· -- Help
Displays the help message and exits.
· -- Autoclose
(Only in Netware) in Netware, mysqld_safe can keep the window. When you disable mysqld_safe NLM, the window does not disappear according to the default settings. Instead, it prompts the user to enter:
** If you want Netware to automatically close the window, use the -- autoclose option in mysqld_safe.
· -- Basedir = path
Path of the MySQL installation directory.
· -- Core-file-size = size
The size of the kernel file that mysqld can create. The option value is passed to ulimit-C.
· -- Datadir = path
The path of the data directory.
· -- Defaults-extra-file = path
Except the option file name read by the common option file. This option must be preferred if given.
· -- Defaults-file = path
The option file name that is read to replace the common option file. This option must be preferred if given.
· -- Ledir = path
Directory that contains the mysqld program. This option is used to explicitly represent the server location.
· -- Log-error = path
Write the error log to the specified file. See section 5.11.1 "error log ".
· -- Mysqld = prog_name
Name of the server program to be started (in the ledir directory ). This option is required if you use the MySQL binary distribution version but have Data Directories other than the binary distribution version.
· -- Mysqld-version = suffix
This option is similar to the -- mysqld option, but you only specify the suffix of the server program name. The basic name is mysqld. For example, if you use -- mysqld-version = max, mysqld_safe to start the mysqld-Max program in the ledir directory. If the -- mysqld-version parameter is null, mysqld_safe uses mysqld in the directory.
· -- Nice = Priority
Use the nice program to set the scheduling priority of the server based on the given value.
· -- No-defaults
Do not read any option files. This option must be preferred if given.
· -- Open-files-Limit = count
The number of files that mysqld can open. The option value is passed to ulimit-n. Please note that you need to use root to start mysqld_safe to ensure proper work!
· -- PID-file = path
Path of the process ID file.
· -- Port = port_num
The port number used for frame listening TCP/IP connection. The port number must be 1024 or greater, unless MySQL runs as a root user.
· -- Skip-character-set-client-handshake
Ignore the character set information sent by the client and use the default Character Set of the server. (Select this option. The action of MySQL is the same as that of MySQL 4.0 ).
· -- Socket = path
The UNIX socket file used for local connection.
· -- Timezone = Zone
Set the TZ time zone environment variable for the given option value. View the valid time zone format in the operating system documentation.
· -- User = {user_name | user_id}
Run the mysqld server with user_name or digital user ID user_id. ("User" in this article refers to the Logon account of the system, rather than the MySQL user in the authorization table ).
When executing mysqld_safe, you must first provide -- defaults-file or -- defaults-extra-option, or do not use the option file. For example, this command does not use the option file:
In contrast to mysqld_safe -- Port = port_num -- defaults-file = file_name, run the following command:
Mysqld_safe -- defaults-file = file_name -- Port = port_num generally, the mysqld_safe script can start the server installed from the source code or binary MySQL distribution edition, even if these distributions install servers in a slightly different location. (See section 2.1.5 "installation layout "). Mysqld_safe expects one of the following conditions to be true:
· You can find the server and database based on the directory that calls mysqld_safe. In the binary distribution version, mysqld_safe looks to be in the working directory of the bin and Data Directories. For the source code distribution version, it is the libexec and VAR directories. If you execute mysqld_safe from the MySQL installation directory, this condition should be met (for example, the binary distribution version is/usr/local/MySQL ).
· If the server and database cannot be found based on the working directory, mysqld_safe tries to locate them through the absolute path. The typical locations are/usr/local/libexec and/usr/local/var. The actual location is determined by the value configured during the build of the distribution edition. If MySQL is installed to the location specified during the configuration, they should be correct.
Because mysqld_safe tries to find the server and database through the working directory, as long as you run mysqld_safe from the MySQL installation directory, you can install the MySQL binary distribution to another location:
Shell> Cd mysql_installation_directoryshell> bin/mysqld_safe & if mysqld_safe fails, even if the call from the MySQL installation directory still fails, you can specify the -- ledir and -- datadir options to indicate the installation directories of servers and databases in your system.
In general, you should not edit the mysqld_safe script. Instead, configure mysqld_safe using the options in the command line option or the [mysqld_safe] section of the my. CNF option file. In general, you do not need to edit mysqld_safe to correctly start the server. However, if you edit it, MySQL will overwrite the modified mysqld_safe version after you upgrade it. Therefore, you should back up the modified version for future reinstallation.
In Netware, mysqld_safe is a Netware loadable module (NLM) That is transplanted from the original Unix shell script. It runs:
1. Check the system and options.
2. Check the MyISAM table.
3. Keep the MySQL server window.
4. Start and monitor mysqld. Restart if it is terminated due to an error.
5. Send the error message of mysqld to the host_name.err file in the data directory.
6. Send the screen output of mysqld_safe to the host_name.safe file in the data directory.

This article from csdn blog http://blog.csdn.net/rj03hou/archive/2010/01/06/5143434.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.