Mysql Security Boot script mysqld_safe details _mysql

Source: Internet
Author: User

Mysqld_safe is recommended for use 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 Run-time information to the error log file. The specific behavior of NetWare is listed later in this section.

Note: To maintain backward compatibility with older versions of MySQL, the MySQL binary distribution still includes safe_mysqld as a Mysqld_safe symbolic link. However, you should not rely on it anymore because it will be deleted in the future.

By default, Mysqld_safe attempts to start an executable Mysqld-max (if present), or start mysqld. The meaning of this behavior is:

· In Linux, Mysql-max RPM relies on the behavior of the Mysqld_safe. The RPM installation performs Mysqld-max, enabling Mysqld_safe to automatically use executable commands from that point on.

· If you install a Mysql-max distribution that includes the Mysqld-max server and later upgrade to a-max version of MySQL, Mysqld_safe still tries to run the old Mysqld-max server. When upgrading, you should manually remove the old Mysqld-max server to ensure that Mysqld_safe runs the new mysqld server.

To bypass the default behavior and explicitly specify which server you want to run, specify--MYSQLD or--mysqld-version options for Mysqld_safe.

Mysqld_safe reads all options from the [mysqld], [Server], and [Mysqld_safe] portions of the options file. To ensure backward compatibility, it also reads the [SAFE_MYSQLD] section, although you should rename this part to [Mysqld_safe] in the MySQL 5.1 installation.

Mysqld_safe supports the following options:

·--help
Displays a help message and exits.
·--autoclose
(only in NetWare) in NetWare, Mysqld_safe can hold the window. When you turn off the Mysqld_safe NLM, the window does not disappear by default. Instead, it prompts the user to enter:
*<NLM has terminated; Press any key to the screen>* if you want NetWare to automatically close the window, use the--autoclose option in Mysqld_safe.
· --Basedir=path
The path to the MySQL installation directory.
· --core-file-size=size
Mysqld the size of the kernel file that can be created. The option value is passed to the ulimit-c.
· --datadir=path
The path to the data directory.
·--defaults-extra-file=path
Except for the option file name that is read by the generic options file. If given, this option must be preferred.
·--defaults-file=path
The option file name that is read instead of the common options file. If given, this option must be preferred.
·--ledir=path
The path to the directory that contains the MYSQLD program. Use this option to explicitly represent the location of the server.
·--log-error=path
Writes the error log to a given file. See section 5.11.1, "error log."
·--mysqld=prog_name
The name of the server program you want to start (in the Ledir directory). This option is required if you are using the MySQL binary distribution but have a data directory other than the binary distribution version.
·--mysqld-version =suffix
This option is similar to the--MYSQLD option, but you specify only the suffix of the server program name. The base name is assumed to be mysqld. For example, if you use the--mysqld-version =max,mysqld_safe to start the Mysqld-max program in the Ledir directory. If the--mysqld-version argument is empty, Mysqld_safe uses the mysqld in the directory.
·--nice=priority
Use the Nice program to set the server's scheduling priority based on the given value.
·--no-defaults
Do not read any option files. If given, this option must be preferred.
·--open-files-limit=count
Mysqld the number of files that can be opened. The option value is passed to the ulimit-n. Please note that you need to start mysqld_safe with root to ensure the correct work!
·--pid-file=path
The path of the process ID file.
·--port=port_num
The port number used to frame listening to TCP/IP connections. The port number must be 1024 or greater unless MySQL is running as the root system user.
·--skip-character-set-client-handshake
Ignores the character set information sent by the client, using the server's default character set. (Choose this option, MySQL's action is the same as MySQL 4.0).
·--socket=path
A UNIX socket file for local connection.
·--timezone=zone
Sets the TZ time zone environment variable for the given option value. Check the legal time zone specified format from the operating system documentation.
·--user={user_name | user_id}
Run the MYSQLD server in User name user_name or digital user ID user_id. (the "user" in this article refers to the system login account, not the MySQL user in the authorization table).

When you perform a mysqld_safe, you must first give--defaults-file or--defaults-extra-option, or do not use the option file. For example, the command will not use the option file:
Mysqld_safe--port=port_num--defaults-file=file_name Instead, use the following command:
Mysqld_safe--defaults-file=file_name--port=port_num General Mysqld_safe scripts can start servers installed from either the source or binary MySQL distribution, even if the distributions install the server to A slightly different position. (see section 2.1.5, "Install Layout"). Mysqld_safe expects one of the following conditions to be true:

· You can find servers and databases based on directories that call Mysqld_safe. In the binary distribution, Mysqld_safe appears in the working directory of the bin and data directories. For the source distribution version, the Libexec and VAR directories. If you are installing a directory from MySQL the mysqld_safe should meet this condition (for example, the binary distribution is/usr/local/mysql).

· If the server and database cannot be located according to the working directory, Mysqld_safe attempts to locate them through an absolute path. Typical locations are/usr/local/libexec and/usr/local/var. The actual location is determined by the values that are configured when the distribution is built, if MySQL is installed at the location specified by the configuration, they should be correct.

Because Mysqld_safe is trying to find servers and databases through the working directory, you can install the MySQL binary distribution to a different location as long as you run Mysqld_safe from the MySQL installation directory:

Shell> CD mysql_installation_directoryshell> Bin/mysqld_safe & If the mysqld_safe fails, even if the directory call from the MySQL installation still fails, You can specify the--ledir and--datadir options to indicate the server and database in your system's installation directory.

Generally, you should not edit the Mysqld_safe script. Instead, use the options in the [Mysqld_safe] section of the command-line option or the MY.CNF option file to configure the Mysqld_safe. You generally do not need to edit Mysqld_safe to start the server correctly. However, if you edit, the future version of MySQL will overwrite your modified mysqld_safe, so you should back up your modified version for future reloading.

In NetWare, Mysqld_safe is a NetWare Loadable Module (NLM), which is ported from the original Unix shell script. It executes:
1. Check system and options.
2. Check the MyISAM table.
3. Keep the MySQL server window.
4. Start and monitor the mysqld and reboot if the error is terminated.
5. Send the MYSQLD error message to the Host_name.err file in the data directory.
6. Send the Mysqld_safe screen output to the Host_name.safe file in the data directory

Related Article

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.