< Day Day Up > |
The MySQL server, mysqld , is the main program that does most of the work in a MySQL installation. The server is accompanied by several related scripts that perform setup operations when you install MySQL or that are helper programs to assist you in starting and stopping the server. This section provides an overview of the server and related programs, and information about server startup scripts. Information about configuring the server itself is given in Section 4.2, "Configuring the MySQL Server." 4.1.1 Overview of the Server-Side Scripts and UtilitiesAll MySQL programs take many different options. However, every MySQL program provides a --help option that you can use to get a description of the program's options. For example, try mysqld --help . You can override default options for all standard programs by specifying options on the command line or in an option file. See Section 3.3, "Specifying Program Options." The following list briefly describes the MySQL server and server-related programs:
There are several other programs that also are run on the server host:
4.1.2 The mysqld-max Extended MySQL ServerA MySQL-Max server is a version of the mysqld MySQL server that has been built to include additional features. The distribution to use depends on your platform:
You can find the MySQL-Max binaries on the MySQL AB Web site at http://dev.mysql.com/downloads/mysql-max-4.0.html. MySQL AB builds the MySQL-Max servers by using the following configure options:
MySQL-Max binary distributions are a convenience for those who wish to install precompiled programs. If you build MySQL using a source distribution, you can build your own Max-like server by enabling the same features at configuration time that the MySQL-Max binary distributions are built with. MySQL-Max servers include the BerkeleyDB ( BDB ) storage engine whenever possible, but not all platforms support BDB . The following table shows which platforms allow MySQL-Max binaries to include BDB :
To find out which storage engines your server supports, issue the following statement: mysql> SHOW ENGINES; Before MySQL 4.1.2, SHOW ENGINES is unavailable. Use the following statement instead and check the value of the variable for the storage engine in which you are interested: mysql> SHOW VARIABLES LIKE 'have_%'; +------------------+----------+ Variable_name Value +------------------+----------+ have_bdb NO have_crypt YES have_innodb YES have_isam NO have_raid NO have_symlink DISABLED have_openssl NO have_query_cache YES +------------------+----------+ The values in the second column indicate the server's level of support for each feature:
A value of NO means that the server was compiled without support for the feature, so it cannot be activated at runtime. A value of DISABLED occurs either because the server was started with an option that disables the feature, or because not all options required to enable it were given. In the latter case, the host_name .err error log file should contain a reason indicating why the option is disabled. One situation in which you might see DISABLED occurs with MySQL 3.23 when the InnoDB storage engine is compiled in. In MySQL 3.23, you must supply at least the innodb_data_file_path option at runtime to set up the InnoDB tablespace. Without this option, InnoDB disables itself. See Section 9.3, "InnoDB in MySQL 3.23." You can specify configuration options for the BDB storage engine, too, but BDB will not disable itself if you do not provide them. See Section 8.4.3, "BDB Startup Options." You might also see DISABLED for the InnoDB , BDB , or ISAM storage engines if the server was compiled to support them, but was started with the --skip-innodb , --skip-bdb , or --skip-isam options at runtime. As of Version 3.23, all MySQL servers support MyISAM tables, because MyISAM is the default storage engine. 4.1.3 The mysqld_safe Server Startup Scriptmysqld_safe is the recommended way to start a mysqld server on Unix and NetWare. mysqld_safe adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log file. NetWare-specific behaviors are listed later in this section. 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 . By default, mysqld_safe tries to start an executable named mysqld-max if it exists, or mysqld otherwise. Be aware of the implications of this behavior:
To override the default behavior and specify explicitly which server you want to run, specify a --mysqld or --mysqld-version option to mysqld_safe . Many of the options to mysqld_safe are the same as the options to mysqld . See Section 4.2.1, "mysqld Command-Line Options." All options specified to mysqld_safe on the command line are passed to mysqld . If you want to use any options that are specific to mysqld_safe and that mysqld doesn't support, do not specify them on the command line. Instead, list them in the [mysqld_safe] group of an option file. See Section 3.3.2, "Using Option Files." mysqld_safe reads all options from the [mysqld] , [server] , and [mysqld_safe] sections in option files. For backward compatibility, it also reads [safe_mysqld] sections, although you should rename such sections to [mysqld_safe] when you begin using MySQL 4.0 or later. mysqld_safe supports the following options:
The mysqld_safe script is written so that it normally can start a server that was installed from either a source or a binary distribution of MySQL, even though these types of distributions typically 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:
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 run 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 specify the --ledir and --datadir options to indicate the directories in which the server and databases are located on your system. Normally, you should not edit the mysqld_safe script. Instead, configure mysqld_safe by using command-line options or options in the [mysqld_safe] section of a my.cnf option file. In rare cases, it might be necessary to edit mysqld_safe to get it to start the server properly. However, if you do this, your modified version of mysqld_safe might be overwritten if you upgrade MySQL in the future, so you should make a copy of your edited version that you can reinstall. On NetWare, mysqld_safe is a NetWare Loadable Module (NLM) that is ported from the original Unix shell script. It does the following:
4.1.4 The mysql.server Server Startup ScriptMySQL distributions on Unix include a script named mysql.server . It can be used on systems such as Linux and Solaris that use System V-style run directories to start and stop system services. It is also used by the Mac OS X Startup Item for MySQL. mysql.server can be found in the support-files directory under your MySQL installation directory or in a MySQL source tree. If you use the Linux server RPM package ( MySQL-server- VERSION .rpm ), the mysql.server script will already have been installed in the /etc/init.d directory with the name mysql . You need not install it manually. See Section 2.2.2, "Installing MySQL on Linux," for more information on the Linux RPM packages. Some vendors provide RPM packages that install a startup script under a different name such as mysqld . If you install MySQL from a source distribution or use a binary distribution format that does not install mysql.server automatically, you can install it manually. Instructions are provided in Section 2.4.3, "Starting and Stopping MySQL Automatically." mysql.server reads options from the [mysql.server] and [mysqld] sections of option files. For backward compatibility, it also reads [mysql_server] sections, although you should rename such sections to [mysql.server] when you begin using MySQL 4.0 or later. 4.1.5 The mysqld_multi Program for Managing Multiple MySQL Serversmysqld_multi is meant for managing several mysqld processes that listen for connections on different Unix socket files and TCP/IP ports. It can start or stop servers, or report their current status. The program searches for groups named [mysqld # ] in my.cnf (or in the file named by the --config-file option). # can be any positive integer. This number is referred to in the following discussion as the option group number, or GNR. Group numbers distinguish option groups from one another and are used as arguments to mysqld_multi to specify which servers you want to start, stop, or obtain a status report for. Options listed in these groups are the same that you would use in the [mysqld] group used for starting mysqld . (See, for example, Section 2.4.3, "Starting and Stopping MySQL Automatically.") However, when using multiple servers it is necessary that each one use its own value for options such as the Unix socket file and TCP/IP port number. For more information on which options must be unique per server in a multiple-server environment, see Section 4.9, "Running Multiple MySQL Servers on the Same Machine." To invoke mysqld_multi , use the following syntax: shell> mysqld_multi [ options ] { start stop report }[ GNR [ , GNR ]...] start , stop , and report indicate which operation you want to perform. You can perform the designated operation on a single server or multiple servers, depending on the GNR list that follows the option name. If there is no list, mysqld_multi performs the operation for all servers in the option file. Each GNR value represents an option group number or range of group numbers. The value should be the number at the end of the group name in the option file. For example, the GNR for a group named [mysqld17] is 17 . To specify a range of numbers, separate the first and last numbers by a dash. The GNR value 10-13 represents groups [mysqld10] through [mysqld13] . Multiple groups or group ranges can be specified on the command line, separated by commas. There must be no whitespace characters (spaces or tabs) in the GNR list; anything after a whitespace character is ignored. This command starts a single server using option group [mysqld17] : shell> mysqld_multi start 17 This command stops several servers, using option groups [mysql8] and [mysqld10] through [mysqld13] : shell> mysqld_multi start 8,10-13 For an example of how you might set up an option file, use this command: shell> mysqld_multi --example mysqld_multi supports the following options:
Some notes about mysqld_multi :
The following example shows how you might set up an option file for use with mysqld_multi . The first and fifth [mysqld # ] group were intentionally left out from the example to illustrate that you can have "gaps" in the option file. This gives you more flexibility. The order in which the mysqld programs are started or stopped depends on the order in which they appear in the option file. # This file should probably be in your home dir (~/.my.cnf) # or /etc/my.cnf # Version 2.1 by Jani Tolonen [mysqld_multi] mysqld = /usr/local/bin/mysqld_safe mysqladmin = /usr/local/bin/mysqladmin user = multi_admin password = multipass [mysqld2] socket = /tmp/mysql.sock2 port = 3307 pid-file = /usr/local/mysql/var2/hostname.pid2 datadir = /usr/local/mysql/var2 language = /usr/local/share/mysql/english user = john [mysqld3] socket = /tmp/mysql.sock3 port = 3308 pid-file = /usr/local/mysql/var3/hostname.pid3 datadir = /usr/local/mysql/var3 language = /usr/local/share/mysql/swedish user = monty [mysqld4] socket = /tmp/mysql.sock4 port = 3309 pid-file = /usr/local/mysql/var4/hostname.pid4 datadir = /usr/local/mysql/var4 language = /usr/local/share/mysql/estonia user = tonu [mysqld6] socket = /tmp/mysql.sock6 port = 3311 pid-file = /usr/local/mysql/var6/hostname.pid6 datadir = /usr/local/mysql/var6 language = /usr/local/share/mysql/japanese user = jani See Section 3.3.2, "Using Option Files." |
< Day Day Up > |