This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-23. For the latest, interactive version please visit https://mariadb.com/kb/.

mysql.server

The mysql.server startup script is in MariaDB distributions on Linux and Unix. It is a wrapper that works as a standard sysVinit script. However, it can be used independently of sysVinit as a regular sh script. The script starts the mariadbd server process by first changing its current working directory to the MariaDB install directory and then starting mariadbd-safe. The script requires the standard sysVinit arguments, such as start, stop, restart, and status. For example:

mysql.server start
mysql.server restart
mysql.server stop
mysql.server status

It can be used on systems such as Linux, Solaris, and Mac OS X.

The mysql.server script starts mariadbd by first changing to the MariaDB install directory and then calling mariadbd_safe.

Using mysql.server

The command to use mysql.server and the general syntax is:

mysql.server [ start | stop | restart | status ] <options> <mariadbd_options>

Options

If an unknown option is provided to mariadbd-safe on the command-line, then it is passed to mariadbd-safe.

mysql.server supports the following options:

OptionDescription
--basedir=pathThe path to the MariaDB installation directory.
--datadir=pathThe path to the MariaDB data directory.
--pid-file=file_nameThe path name of the file in which the server should write its process ID. If not provided, the default, host_name.pid is used.
--service-startup-timeout=file_nameHow 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).
--use-mysqld_safeUse mariadbd-safe to start the server. This is the default.
--use-managerUse Instance Manager to start the server.
--user=user_nameThe login user name to use for running mariadbd.

Option Files

In addition to reading options from the command-line, mysql.server can also read options from option files.

The following options relate to how MariaDB command-line tools handles option files. They must be given as the first argument on the command-line:

OptionDescription
--print-defaultsPrint the program argument list and exit.
--no-defaultsDon't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

Option Groups

mysql.server reads options from the following option groups from option files:

GroupDescription
[mysql.server] Options read by mysql.server, which includes both MariaDB Server and MySQL Server.

mysql.server also reads options from the following server option groups from option files:

GroupDescription
[mysqld] Options read by mysqld, which includes both MariaDB Server and MySQL Server.
[server]Options read by MariaDB Server.
[mysqld-X.Y] Options read by a specific version of mysqld, which includes both MariaDB Server and MySQL Server. For example, [mysqld-5.5].
[mariadbd]Options read by MariaDB Server.
[mariadbd-X.Y] Options read by a specific version of MariaDB Server.
[client-server]Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients.
[galera] Options read by a galera-capable MariaDB Server. Available on systems compiled with Galera support.

Customizing mysql.server

If you have installed MariaDB to a non-standard location, then you may need to edit the mysql.server script to get it to work right.

If you do not want to edit the mysql.server script itself, then mysql.server also sources a few other sh scripts. These files can be used to set any variables that might be needed to make the script work in your specific environment. The files are:

  • /etc/default/mysql
  • /etc/sysconfig/mysql
  • /etc/conf.d/mysql

Installed Locations

mysql.server can be found in the support-files directory under your MariaDB installation directory or in a MariaDB source distribution.

Installed SysVinit Locations

On systems that use sysVinit, mysql.server may also be installed in other locations and with other names.

If you installed MariaDB on Linux using RPMs, then the mysql.server script will be installed into the /etc/init.d directory with the name mysql. You need not install it manually.

Manually Installing with SysVinit

If you install MariaDB from source or from a binary tarball that does not install mysql.server automatically, and if you are on a system that uses sysVinit, then you can manually install mysql.server with sysVinit. This is usually done by copying it to /etc/init.d/ and then creating specially named symlinks in the appropriate /etc/rcX.d/ directories (where 'X' is a number between 0 and 6).

In the examples below we will follow the historical convention of renaming the mysql.server script to 'mysql' when we copy it to /etc/init.d/.

The first step for most Linux distributions is to copy the mysql.server script to /etc/init.d/ and make it executable:

cd /path/to/your/mariadb-version/support-files/
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql

Now all that is needed is to create the specially-named symlinks. On both RPM and Debian-based Linux distributions there are tools which do this for you. Consult your distribution's documentation if neither of these work for you and follow their instructions for generating the symlinks or creating them manually.

On RPM-based distributions (like Fedora and CentOS), you use chkconfig:

chkconfig --add mysql
chkconfig --level 345 mysql on

On Debian-based distributions you use update-rc.d:

update-rc.d mysql defaults

On FreeBSD, the location for startup scripts is /usr/local/etc/rc.d/ and when you copy the mysql.server script there you should rename it so that it matches the *.sh pattern, like so:

cd /path/to/your/mariadb/support-files/
cp mysql.server /usr/local/etc/rc.d/mysql.server.sh

As stated above, consult your distribution's documentation for more information on starting services like MariaDB at system startup.

See mariadbd startup options for information on configuration options for mariadbd.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.