Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, February 10, 2021

mysql.server (1)


mysql.server - MySQL server startup script


mysql {start|stop}


MYSQL.SERVER(1)              MySQL Database System             MYSQL.SERVER(1)

       mysql.server - MySQL server startup script

       mysql {start|stop}

       MySQL distributions on Unix and Unix-like system include a script named
       mysql.server, which starts the MySQL server using mysqld_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 or mysql. In
       the following discussion, adjust the name mysql.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 and mysqld_safe are
           not installed because they are unnecessary. For more information,
           see Section 2.5.10, "Managing MySQL Server with systemd".

       To start or stop the server manually using the mysql.server script,
       invoke it from the command line with start or stop arguments:

           shell> mysql.server start
           shell> mysql.server stop

       mysql.server changes location to the MySQL installation directory, then
       invokes mysqld_safe. To run the server as some specific user, add an
       appropriate user 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 edit mysql.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 runs mysqld_safe. If you do this, your
       modified version of mysql.server may be overwritten if you upgrade
       MySQL in the future; make a copy of your edited version that you can

       mysql.server stop stops the server by sending a signal to it. You can
       also stop the server manually by executing mysqladmin 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*

       o   If you use the Linux server RPM package (MySQL-server-VERSION.rpm),
           or a native Linux package installation, the mysql.server script may
           be installed in the /etc/init.d directory with the name mysqld or
           mysql. See Section 2.5.5, "Installing MySQL on Linux Using RPM
           Packages from Oracle", for more information on the Linux RPM

       o   If you install MySQL from a source distribution or using a binary
           distribution format that does not install mysql.server
           automatically, you can install the script manually. It can be found
           in the support-files directory under the MySQL installation
           directory or in a MySQL source tree. Copy the script to the
           /etc/init.d directory with the name mysql and make it executable:

               shell> cp mysql.server /etc/init.d/mysql
               shell> chmod +x /etc/init.d/mysql

           After installing the script, the commands needed to activate it to
           run at system startup depend on your operating system. On Linux,
           you can use chkconfig:

               shell> chkconfig --add mysql

           On some Linux systems, the following command also seems to be
           necessary to fully enable the mysql script:

               shell> chkconfig --level 345 mysql on

       o   On FreeBSD, startup scripts generally should go in
           /usr/local/etc/rc.d/. Install the mysql.server script as
           /usr/local/etc/rc.d/mysql.server.sh to enable automatic startup.
           The rc(8) manual page states that scripts in this directory are
           executed only if their base name matches the *.sh shell file name
           pattern. Any other files or directories present within the
           directory are silently ignored.

       o   As an alternative to the preceding setup, some operating systems
           also use /etc/rc.local or /etc/init.d/boot.local to 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 &'

       o   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 for mysql.server in a global /etc/my.cnf file. A
       typical my.cnf file might look like this:


       The mysql.server script supports the options shown in the following
       table. If specified, they must be placed in an option file, not on the
       command line.  mysql.server supports only start and stop as
       command-line arguments.

       Table 4.3. mysql.server Option-File Options
       |Option Name      | Description         | Type           |
       |basedir          | Path to MySQL       | directory name |
       |                 | installation        |                |
       |                 | directory           |                |
       |datadir          | Path to MySQL data  | directory name |
       |                 | directory           |                |
       |pid-file         | File in which       | file name      |
       |                 | server should write |                |
       |                 | its process ID      |                |
       |service-startup- | How long to wait    | integer        |
       |timeout          | for server startup  |                |

       o   basedir=dir_name

           The path to the MySQL installation directory.

       o   datadir=dir_name

           The path to the MySQL data directory.

       o   pid-file=file_name

           The path name of the file in which the server should write its
           process ID.

           If this option is not given, mysql.server uses a default value of
           host_name.pid. The PID file value passed to mysqld_safe overrides
           any value specified in the [mysqld_safe] option file group. Because
           mysql.server reads the [mysqld] option file group but not the
           [mysqld_safe] group, you can ensure that mysqld_safe gets the same
           value when invoked from mysql.server as when invoked manually by
           putting the same pid-file setting in both the [mysqld_safe] and
           [mysqld] groups.

       o   service-startup-timeout=seconds

           How 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

       Copyright (C) 1997, 2018, Oracle and/or its affiliates. All rights

       This documentation is free software; you can redistribute it and/or
       modify it only under the terms of the GNU General Public License as
       published by the Free Software Foundation; version 2 of the License.

       This documentation is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       General Public License for more details.

       You should have received a copy of the GNU General Public License along
       with the program; if not, write to the Free Software Foundation, Inc.,
       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see

       See attributes(7) for descriptions of the following attributes:

       |Availability   | database/mysql-57 |
       |Stability      | Uncommitted       |
       For more information, please refer to the MySQL Reference Manual, which
       may already be installed locally and which is also available online at

       Oracle Corporation (http://dev.mysql.com/).

       This software was built from source available at
       https://github.com/oracle/solaris-userland.  The original community
       source was downloaded from

       Further information about this software can be found on the open source
       community website at https://dev.mysql.com/.

MySQL 5.7                         03/03/2018                   MYSQL.SERVER(1)