1MYSQL.SERVER(1) MySQL Database System MYSQL.SERVER(1)
2
3
4
6 mysql.server - MySQL server startup script
7
9 mysql {start|stop}
10
12 MySQL distributions on Unix and Unix-like system include a script named
13 mysql.server, which starts the MySQL server using mysqld_safe. It can
14 be used on systems such as Linux and Solaris that use System V-style
15 run directories to start and stop system services. It is also used by
16 the macOS Startup Item for MySQL.
17
18 mysql.server is the script name as used within the MySQL source tree.
19 The installed name might be different; for example, mysqld or mysql. In
20 the following discussion, adjust the name mysql.server as appropriate
21 for your system.
22
23 Note
24 For some Linux platforms, MySQL installation from RPM or Debian
25 packages includes systemd support for managing MySQL server startup
26 and shutdown. On these platforms, mysql.server and mysqld_safe are
27 not installed because they are unnecessary. For more information,
28 see Section 2.5.9, “Managing MySQL Server with systemd”.
29
30 To start or stop the server manually using the mysql.server script,
31 invoke it from the command line with start or stop arguments:
32
33 shell> mysql.server start
34 shell> mysql.server stop
35
36 mysql.server changes location to the MySQL installation directory, then
37 invokes mysqld_safe. To run the server as some specific user, add an
38 appropriate user option to the [mysqld] group of the global /etc/my.cnf
39 option file, as shown later in this section. (It is possible that you
40 must edit mysql.server if you've installed a binary distribution of
41 MySQL in a nonstandard location. Modify it to change location into the
42 proper directory before it runs mysqld_safe. If you do this, your
43 modified version of mysql.server may be overwritten if you upgrade
44 MySQL in the future; make a copy of your edited version that you can
45 reinstall.)
46
47 mysql.server stop stops the server by sending a signal to it. You can
48 also stop the server manually by executing mysqladmin shutdown.
49
50 To start and stop MySQL automatically on your server, you must add
51 start and stop commands to the appropriate places in your /etc/rc*
52 files:
53
54 · If you use the Linux server RPM package (MySQL-server-VERSION.rpm),
55 or a native Linux package installation, the mysql.server script may
56 be installed in the /etc/init.d directory with the name mysqld or
57 mysql. See Section 2.5.4, “Installing MySQL on Linux Using RPM
58 Packages from Oracle”, for more information on the Linux RPM
59 packages.
60
61 · If you install MySQL from a source distribution or using a binary
62 distribution format that does not install mysql.server
63 automatically, you can install the script manually. It can be found
64 in the support-files directory under the MySQL installation
65 directory or in a MySQL source tree. Copy the script to the
66 /etc/init.d directory with the name mysql and make it executable:
67
68 shell> cp mysql.server /etc/init.d/mysql
69 shell> chmod +x /etc/init.d/mysql
70
71 After installing the script, the commands needed to activate it to
72 run at system startup depend on your operating system. On Linux,
73 you can use chkconfig:
74
75 shell> chkconfig --add mysql
76
77 On some Linux systems, the following command also seems to be
78 necessary to fully enable the mysql script:
79
80 shell> chkconfig --level 345 mysql on
81
82 · On FreeBSD, startup scripts generally should go in
83 /usr/local/etc/rc.d/. Install the mysql.server script as
84 /usr/local/etc/rc.d/mysql.server.sh to enable automatic startup.
85 The rc(8) manual page states that scripts in this directory are
86 executed only if their base name matches the *.sh shell file name
87 pattern. Any other files or directories present within the
88 directory are silently ignored.
89
90 · As an alternative to the preceding setup, some operating systems
91 also use /etc/rc.local or /etc/init.d/boot.local to start
92 additional services on startup. To start up MySQL using this
93 method, append a command like the one following to the appropriate
94 startup file:
95
96 /bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'
97
98 · For other systems, consult your operating system documentation to
99 see how to install startup scripts.
100
101 mysql.server reads options from the [mysql.server] and [mysqld]
102 sections of option files. For backward compatibility, it also reads
103 [mysql_server] sections, but to be current you should rename such
104 sections to [mysql.server].
105
106 You can add options for mysql.server in a global /etc/my.cnf file. A
107 typical my.cnf file might look like this:
108
109 [mysqld]
110 datadir=/usr/local/mysql/var
111 socket=/var/tmp/mysql.sock
112 port=3306
113 user=mysql
114 [mysql.server]
115 basedir=/usr/local/mysql
116
117 The mysql.server script supports the options shown in the following
118 table. If specified, they must be placed in an option file, not on the
119 command line. mysql.server supports only start and stop as
120 command-line arguments.
121
122 Table 4.3. mysql.server Option-File Options
123 ┌─────────────────┬─────────────────────┬────────────────┐
124 │Option Name │ Description │ Type │
125 ├─────────────────┼─────────────────────┼────────────────┤
126 │basedir │ Path to MySQL │ Directory name │
127 │ │ installation │ │
128 │ │ directory │ │
129 ├─────────────────┼─────────────────────┼────────────────┤
130 │datadir │ Path to MySQL data │ Directory name │
131 │ │ directory │ │
132 ├─────────────────┼─────────────────────┼────────────────┤
133 │pid-file │ File in which │ File name │
134 │ │ server should write │ │
135 │ │ its process ID │ │
136 ├─────────────────┼─────────────────────┼────────────────┤
137 │service-startup- │ How long to wait │ Integer │
138 │timeout │ for server startup │ │
139 └─────────────────┴─────────────────────┴────────────────┘
140
141 · basedir=dir_name
142
143 The path to the MySQL installation directory.
144
145 · datadir=dir_name
146
147 The path to the MySQL data directory.
148
149 · pid-file=file_name
150
151 The path name of the file in which the server should write its
152 process ID. The server creates the file in the data directory
153 unless an absolute path name is given to specify a different
154 directory.
155
156 If this option is not given, mysql.server uses a default value of
157 host_name.pid. The PID file value passed to mysqld_safe overrides
158 any value specified in the [mysqld_safe] option file group. Because
159 mysql.server reads the [mysqld] option file group but not the
160 [mysqld_safe] group, you can ensure that mysqld_safe gets the same
161 value when invoked from mysql.server as when invoked manually by
162 putting the same pid-file setting in both the [mysqld_safe] and
163 [mysqld] groups.
164
165 · service-startup-timeout=seconds
166
167 How long in seconds to wait for confirmation of server startup. If
168 the server does not start within this time, mysql.server exits with
169 an error. The default value is 900. A value of 0 means not to wait
170 at all for startup. Negative values mean to wait forever (no
171 timeout).
172
174 Copyright © 1997, 2019, Oracle and/or its affiliates. All rights
175 reserved.
176
177 This documentation is free software; you can redistribute it and/or
178 modify it only under the terms of the GNU General Public License as
179 published by the Free Software Foundation; version 2 of the License.
180
181 This documentation is distributed in the hope that it will be useful,
182 but WITHOUT ANY WARRANTY; without even the implied warranty of
183 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
184 General Public License for more details.
185
186 You should have received a copy of the GNU General Public License along
187 with the program; if not, write to the Free Software Foundation, Inc.,
188 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
189 http://www.gnu.org/licenses/.
190
191
193 For more information, please refer to the MySQL Reference Manual, which
194 may already be installed locally and which is also available online at
195 http://dev.mysql.com/doc/.
196
198 Oracle Corporation (http://dev.mysql.com/).
199
200
201
202MySQL 8.0 02/20/2019 MYSQL.SERVER(1)