PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
MySQL distributions on Unix and Unix-like system include a script namedmysql.server, which starts the MySQL server usingmysqld_safe. 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 macOS Startup Item for MySQL.
mysql.server is the script name as used within the MySQL source tree. The installed name might be different (for example,mysqld ormysql). In the following discussion, adjust the namemysql.server as appropriate for your system.
For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms,mysql.server andmysqld_safe are not installed because they are unnecessary. For more information, seeSection 2.5.9, “Managing MySQL Server with systemd”.
To start or stop the server manually using themysql.server script, invoke it from the command line withstart orstop arguments:
mysql.server startmysql.server stopmysql.server changes location to the MySQL installation directory, then invokesmysqld_safe. To run the server as some specific user, add an appropriateuser option to the[mysqld] group of the global/etc/my.cnf option file, as shown later in this section. (It is possible that you must editmysql.server if you've installed a binary distribution of MySQL in a nonstandard location. Modify it to change location into the proper directory before it runsmysqld_safe. If you do this, your modified version ofmysql.server may be overwritten if you upgrade MySQL in the future; make a copy of your edited version that you can reinstall.)
mysql.server stop stops the server by sending a signal to it. You can also stop the server manually by executingmysqladmin shutdown.
To start and stop MySQL automatically on your server, you must add start and stop commands to the appropriate places in your/etc/rc* files:
If you use the Linux server RPM package (
MySQL-server-), or a native Linux package installation, themysql.server script may be installed in theVERSION.rpm/etc/init.ddirectory with the namemysqldormysql. SeeSection 2.5.4, “Installing MySQL on Linux Using RPM Packages from Oracle”, for more information on the Linux RPM packages.If you install MySQL from a source distribution or using a binary distribution format that does not installmysql.server automatically, you can install the script manually. It can be found in the
support-filesdirectory under the MySQL installation directory or in a MySQL source tree. Copy the script to the/etc/init.ddirectory with the namemysql and make it executable:cp mysql.server /etc/init.d/mysqlchmod +x /etc/init.d/mysqlAfter installing the script, the commands needed to activate it to run at system startup depend on your operating system. On Linux, you can usechkconfig:
chkconfig --add mysqlOn some Linux systems, the following command also seems to be necessary to fully enable themysql script:
chkconfig --level 345 mysql onOn FreeBSD, startup scripts generally should go in
/usr/local/etc/rc.d/. Install themysql.serverscript as/usr/local/etc/rc.d/mysql.server.shto enable automatic startup. Therc(8)manual page states that scripts in this directory are executed only if their base name matches the*.shshell file name pattern. Any other files or directories present within the directory are silently ignored.As an alternative to the preceding setup, some operating systems also use
/etc/rc.localor/etc/init.d/boot.localto start additional services on startup. To start up MySQL using this method, append a command like the one following to the appropriate startup file:/bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'For other systems, consult your operating system documentation to see how to install startup scripts.
mysql.server reads options from the[mysql.server] and[mysqld] sections of option files. For backward compatibility, it also reads[mysql_server] sections, but to be current you should rename such sections to[mysql.server].
You can add options formysql.server in a global/etc/my.cnf file. A typicalmy.cnf file might look like this:
[mysqld]datadir=/usr/local/mysql/varsocket=/var/tmp/mysql.sockport=3306user=mysql[mysql.server]basedir=/usr/local/mysql Themysql.server script supports the options shown in the following table. If specified, theymust be placed in an option file, not on the command line.mysql.server supports onlystart andstop as command-line arguments.
Table 6.8 mysql.server Option-File Options
| Option Name | Description | Type |
|---|---|---|
basedir | Path to MySQL installation directory | Directory name |
datadir | Path to MySQL data directory | Directory name |
pid-file | File in which server should write its process ID | File name |
service-startup-timeout | How long to wait for server startup | Integer |
The path to the MySQL installation directory.
The path to the MySQL data directory.
The path name of the file in which the server should write its process ID. The server creates the file in the data directory unless an absolute path name is given to specify a different directory.
If this option is not given,mysql.server uses a default value of
. The PID file value passed tomysqld_safe overrides any value specified in thehost_name.pid[mysqld_safe]option file group. Becausemysql.server reads the[mysqld]option file group but not the[mysqld_safe]group, you can ensure thatmysqld_safe gets the same value when invoked frommysql.server as when invoked manually by putting the samepid-filesetting in both the[mysqld_safe]and[mysqld]groups.service-startup-timeout=secondsHow long in seconds to wait for confirmation of server startup. If the server does not start within this time,mysql.server exits with an error. The default value is 900. A value of 0 means not to wait at all for startup. Negative values mean to wait forever (no timeout).
PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb