1MYSQLD_SAFE(1) MySQL Database System MYSQLD_SAFE(1)
2
3
4
6 mysqld_safe - MySQL server startup script
7
9 mysqld_safe options
10
12 mysqld_safe is the recommended way to start a mysqld server on Unix and
13 NetWare. mysqld_safe adds some safety features such as restarting the
14 server when an error occurs and logging runtime information to an error
15 log file. Descriptions of error logging and NetWare-specific behaviors
16 are given later in this section.
17
18 Note
19 In MySQL 5.1.20 (only), the default error logging behavior with
20 mysqld_safe is to write errors to syslog on systems that support
21 the logger program. This differs from the default behavior of
22 writing an error log file for other versions.
23
24 In 5.1.20, logging to syslog may fail to operate correctly in some
25 cases; if so, use --skip-syslog to use the default log file or
26 --log-error=file_name to specify a log file name explicitly.
27
28 mysqld_safe tries to start an executable named mysqld. To override the
29 default behavior and specify explicitly the name of the server you want
30 to run, specify a --mysqld or --mysqld-version option to mysqld_safe.
31 You can also use --ledir to indicate the directory where mysqld_safe
32 should look for the server.
33
34 Many of the options to mysqld_safe are the same as the options to
35 mysqld. See Section 5.1.2, “Server Command Options”.
36
37 Options unknown to mysqld_safe are passed to mysqld if they are
38 specified on the command line, but ignored if they are specified in the
39 [mysqld_safe] group of an option file. See Section 4.2.3.3, “Using
40 Option Files”.
41
42 mysqld_safe reads all options from the [mysqld], [server], and
43 [mysqld_safe] sections in option files. For example, if you specify a
44 [mysqld] section like this, mysqld_safe will find and use the
45 --log-error option:
46
47 [mysqld]
48 log-error=error.log
49
50 For backward compatibility, mysqld_safe also reads [safe_mysqld]
51 sections, although you should rename such sections to [mysqld_safe] in
52 MySQL 5.1 installations.
53
54 mysqld_safe supports the options in the following list. It also reads
55 option files and supports the options for processing them described at
56 Section 4.2.3.3.1, “Command-Line Options that Affect Option-File
57 Handling”.
58
59 · --help
60
61 Display a help message and exit.
62
63 · --autoclose
64
65 (NetWare only) On NetWare, mysqld_safe provides a screen presence.
66 When you unload (shut down) the mysqld_safe NLM, the screen does
67 not by default go away. Instead, it prompts for user input:
68
69 *<NLM has terminated; Press any key to close the screen>*
70
71 If you want NetWare to close the screen automatically instead, use
72 the --autoclose option to mysqld_safe.
73
74 · --basedir=path
75
76 The path to the MySQL installation directory.
77
78 · --core-file-size=size
79
80 The size of the core file that mysqld should be able to create. The
81 option value is passed to ulimit -c.
82
83 · --datadir=path
84
85 The path to the data directory.
86
87 · --defaults-extra-file=path
88
89 The name of an option file to be read in addition to the usual
90 option files. This must be the first option on the command line if
91 it is used. If the file does not exist or is otherwise
92 inaccessible, the server will exit with an error.
93
94 · --defaults-file=file_name
95
96 The name of an option file to be read instead of the usual option
97 files. This must be the first option on the command line if it is
98 used.
99
100 · --ledir=path
101
102 If mysqld_safe cannot find the server, use this option to indicate
103 the path name to the directory where the server is located.
104
105 · --log-error=file_name
106
107 Write the error log to the given file. See Section 5.2.2, “The
108 Error Log”.
109
110 · --mysqld=prog_name
111
112 The name of the server program (in the ledir directory) that you
113 want to start. This option is needed if you use the MySQL binary
114 distribution but have the data directory outside of the binary
115 distribution. If mysqld_safe cannot find the server, use the
116 --ledir option to indicate the path name to the directory where the
117 server is located.
118
119 · --mysqld-version=suffix
120
121 This option is similar to the --mysqld option, but you specify only
122 the suffix for the server program name. The basename is assumed to
123 be mysqld. For example, if you use --mysqld-version=debug,
124 mysqld_safe starts the mysqld-debug program in the ledir directory.
125 If the argument to --mysqld-version is empty, mysqld_safe uses
126 mysqld in the ledir directory.
127
128 · --nice=priority
129
130 Use the nice program to set the server´s scheduling priority to the
131 given value.
132
133 · --no-defaults
134
135 Do not read any option files. This must be the first option on the
136 command line if it is used.
137
138 · --open-files-limit=count
139
140 The number of files that mysqld should be able to open. The option
141 value is passed to ulimit -n. Note that you need to start
142 mysqld_safe as root for this to work properly!
143
144 · --pid-file=file_name
145
146 The path name of the process ID file.
147
148 · --port=port_num
149
150 The port number that the server should use when listening for
151 TCP/IP connections. The port number must be 1024 or higher unless
152 the server is started by the root system user.
153
154 · --skip-kill-mysqld
155
156 Do not try to kill stray mysqld processes at startup. This option
157 works only on Linux.
158
159 · --socket=path
160
161 The Unix socket file that the server should use when listening for
162 local connections.
163
164 · --syslog, --skip-syslog
165
166 --syslog causes error messages to be sent to syslog on systems that
167 support the logger program. --skip-syslog suppresses the use of
168 syslog; messages are written to an error log file. These options
169 were added in MySQL 5.1.20.
170
171 · --syslog-tag=tag
172
173 For logging to syslog, messages from mysqld_safe and mysqld are
174 written with a tag of mysqld_safe and mysqld, respectively. To
175 specify a suffix for the tag, use --syslog-tag=tag, which modifies
176 the tags to be mysqld_safe-tag and mysqld-tag. This option was
177 added in MySQL 5.1.21.
178
179 · --timezone=timezone
180
181 Set the TZ time zone environment variable to the given option
182 value. Consult your operating system documentation for legal time
183 zone specification formats.
184
185 · --user={user_name|user_id}
186
187 Run the mysqld server as the user having the name user_name or the
188 numeric user ID user_id. (“User” in this context refers to a system
189 login account, not a MySQL user listed in the grant tables.)
190
191 If you execute mysqld_safe with the --defaults-file or
192 --defaults-extra-file option to name an option file, the option must be
193 the first one given on the command line or the option file will not be
194 used. For example, this command will not use the named option file:
195
196 mysql> mysqld_safe --port=port_num --defaults-file=file_name
197
198 Instead, use the following command:
199
200 mysql> mysqld_safe --defaults-file=file_name --port=port_num
201
202 The mysqld_safe script is written so that it normally can start a
203 server that was installed from either a source or a binary distribution
204 of MySQL, even though these types of distributions typically install
205 the server in slightly different locations. (See Section 2.1.5,
206 “Installation Layouts”.) mysqld_safe expects one of the following
207 conditions to be true:
208
209 · The server and databases can be found relative to the working
210 directory (the directory from which mysqld_safe is invoked). For
211 binary distributions, mysqld_safe looks under its working directory
212 for bin and data directories. For source distributions, it looks
213 for libexec and var directories. This condition should be met if
214 you execute mysqld_safe from your MySQL installation directory (for
215 example, /usr/local/mysql for a binary distribution).
216
217 · If the server and databases cannot be found relative to the working
218 directory, mysqld_safe attempts to locate them by absolute path
219 names. Typical locations are /usr/local/libexec and /usr/local/var.
220 The actual locations are determined from the values configured into
221 the distribution at the time it was built. They should be correct
222 if MySQL is installed in the location specified at configuration
223 time.
224
225 Because mysqld_safe tries to find the server and databases relative to
226 its own working directory, you can install a binary distribution of
227 MySQL anywhere, as long as you run mysqld_safe from the MySQL
228 installation directory:
229
230 shell> cd mysql_installation_directory
231 shell> bin/mysqld_safe &
232
233 If mysqld_safe fails, even when invoked from the MySQL installation
234 directory, you can specify the --ledir and --datadir options to
235 indicate the directories in which the server and databases are located
236 on your system.
237
238 When you use mysqld_safe to start mysqld, mysqld_safe arranges for
239 error (and notice) messages from itself and from mysqld to go to the
240 same destination.
241
242 As of MySQL 5.1.20, there are several mysqld_safe options for
243 controlling the destination of these messages:
244
245 · --syslog: Write error messages to syslog on systems that support
246 the logger program.
247
248 · --skip-syslog: Do not write error messages to syslog. Messages are
249 written to the default error log file (host_name.err in the data
250 directory), or to a named file if the --log-error option is given.
251
252 · --log-error=file_name: Write error messages to the named error
253 file.
254
255 If none of these options is given, the default is --skip-syslog.
256
257 Note
258 In MySQL 5.1.20 only, the default is --syslog. This differs from
259 logging behavior for other versions of MySQL, for which the default
260 is to write messages to the default error log file.
261
262 If --syslog and --log-error are both given, a warning is issued and
263 --log-error takes precedence.
264
265 When mysqld_safe writes a message, notices go to the logging
266 destination (syslog or the error log file) and stdout. Errors go to the
267 logging destination and stderr.
268
269 Before MySQL 5.1.20, error logging is controlled only with the
270 --log-error option. If it is given, messages go to the named error
271 file. Otherwise, messages go to the default error file.
272
273 Normally, you should not edit the mysqld_safe script. Instead,
274 configure mysqld_safe by using command-line options or options in the
275 [mysqld_safe] section of a my.cnf option file. In rare cases, it might
276 be necessary to edit mysqld_safe to get it to start the server
277 properly. However, if you do this, your modified version of mysqld_safe
278 might be overwritten if you upgrade MySQL in the future, so you should
279 make a copy of your edited version that you can reinstall.
280
281 On NetWare, mysqld_safe is a NetWare Loadable Module (NLM) that is
282 ported from the original Unix shell script. It starts the server as
283 follows:
284
285 1. Runs a number of system and option checks.
286
287 2. Runs a check on MyISAM tables.
288
289 3. Provides a screen presence for the MySQL server.
290
291 4. Starts mysqld, monitors it, and restarts it if it terminates in
292 error.
293
294 5. Sends error messages from mysqld to the host_name.err file in the
295 data directory.
296
297 6. Sends mysqld_safe screen output to the host_name.safe file in the
298 data directory.
299
301 Copyright © 1997, 2011, Oracle and/or its affiliates. All rights
302 reserved.
303
304 This documentation is free software; you can redistribute it and/or
305 modify it only under the terms of the GNU General Public License as
306 published by the Free Software Foundation; version 2 of the License.
307
308 This documentation is distributed in the hope that it will be useful,
309 but WITHOUT ANY WARRANTY; without even the implied warranty of
310 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
311 General Public License for more details.
312
313 You should have received a copy of the GNU General Public License along
314 with the program; if not, write to the Free Software Foundation, Inc.,
315 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
316 http://www.gnu.org/licenses/.
317
318
320 For more information, please refer to the MySQL Reference Manual, which
321 may already be installed locally and which is also available online at
322 http://dev.mysql.com/doc/.
323
325 Oracle Corporation (http://dev.mysql.com/).
326
327
328
329MySQL 5.1 10/26/2011 MYSQLD_SAFE(1)