2
3
4
6 mysqld_safe - MySQL server startup script
7 safe_mysqld - MySQL server startup script
8
10 mysqld_safe options
11
13 mysqld_safe is the recommended way to start a mysqld server on Unix and
14 NetWare. mysqld_safe adds some safety features such as restarting the
15 server when an error occurs and logging runtime information to an error
16 log file. NetWare-specific behaviors are listed later in this section.
17
18 Note: To preserve backward compatibility with older versions of MySQL,
19 MySQL binary distributions still include safe_mysqld as a symbolic link
20 to mysqld_safe. However, you should not rely on this because it is
21 removed as of MySQL 5.1.
22
23 By default, mysqld_safe before MySQL 5.0.27 tries to start an
24 executable named mysqld-max if it exists, and mysqld otherwise. Be
25 aware of the implications of this behavior:
26
27 · On Linux, the MySQL-Max RPM relies on this mysqld_safe behavior. The
28 RPM installs an executable named mysqld-max, which causes
29 mysqld_safe to automatically use that executable rather than mysqld
30 from that point on.
31
32 · If you install a MySQL-Max distribution that includes a server named
33 mysqld-max, and then upgrade later to a non-Max version of MySQL,
34 mysqld_safe will still attempt to run the old mysqld-max server. If
35 you perform such an upgrade, you should manually remove the old
36 mysqld-max server to ensure that mysqld_safe runs the new mysqld
37 server.
38
39
40To override the default behavior and specify explicitly the name of the server
41you want to run, specify a --mysqld or --mysqld-version option to mysqld_safe.
42You can also use --ledir to indicate the directory where mysqld_safe should
43look for the server.
44
45Many of the options to mysqld_safe are the same as the options to mysqld. See
46the section called “COMMAND OPTIONS”.
47
48All options specified to mysqld_safe on the command line are passed to mysqld.
49If you want to use any options that are specific to mysqld_safe and that
51them in the [mysqld_safe] group of an option file. See Section 3.2, “Using
52Option Files”.
53
55sections in option files. For backward compatibility, it also reads
56[safe_mysqld] sections, although you should rename such sections to
57[mysqld_safe] in MySQL 5.0 installations.
58
60
61· --help
62
63 Display a help message and exit. (Added in MySQL 5.0.3)
64
65· --autoclose
66
67 (NetWare only) On NetWare, mysqld_safe provides a screen presence. When you
68 unload (shut down) the mysqld_safe NLM, the screen does not by default go
69 away. Instead, it prompts for user input:
70
71 *<NLM has terminated; Press any key to close the screen>*
72If you want NetWare to close the screen automatically instead, use the
74
75· --basedir=path
76
77 The path to the MySQL installation directory.
78
79· --core-file-size=size
80
81 The size of the core file that mysqld should be able to create. The option
82 value is passed to ulimit -c.
83
84· --datadir=path
85
86 The path to the data directory.
87
88· --defaults-extra-file=path
89
90 The name of an option file to be read in addition to the usual option
91 files. This must be the first option on the command line if it is used. As
92 of MySQL 5.0.6, if the file does not exist or is otherwise inaccessible,
93 the server will exit with an error.
94
95· --defaults-file=file_name
96
97 The name of an option file to be read instead of the usual option files.
98 This must be the first option on the command line if it is used.
99
100· --ledir=path
101
102 If mysqld_safe cannot find the server, use this option to indicate the
103 pathname 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 9.1, “The Error Log”.
108
109· --mysqld=prog_name
110
111 The name of the server program (in the ledir directory) that you want to
112 start. This option is needed if you use the MySQL binary distribution but
113 have the data directory outside of the binary distribution. If mysqld_safe
114 cannot find the server, use the --ledir option to indicate the pathname to
115 the directory where the server is located.
116
117· --mysqld-version=suffix
118
119 This option is similar to the --mysqld option, but you specify only the
120 suffix for the server program name. The basename is assumed to be mysqld.
121 For example, if you use --mysqld-version=debug, mysqld_safe starts the
122 mysqld-debug program in the ledir directory. If the argument to
123 --mysqld-version is empty, mysqld_safe uses mysqld in the ledir directory.
124
125· --nice=priority
126
127 Use the nice program to set the server's scheduling priority to the given
128 value.
129
130· --no-defaults
131
132 Do not read any option files. This must be the first option on the command
133 line if it is used.
134
135· --open-files-limit=count
136
137 The number of files that mysqld should be able to open. The option value is
138 passed to ulimit -n. Note that you need to start mysqld_safe as root for
139 this to work properly!
140
141· --pid-file=file_name
142
143 The pathname of the process ID file.
144
145· --port=port_num
146
147 The port number that the server should use when listening for TCP/IP
148 connections. The port number must be 1024 or higher unless the server is
149 started by the root system user.
150
151· --socket=path
152
153 The Unix socket file that the server should use when listening for local
154 connections.
155
156· --timezone=timezone
157
158 Set the TZ time zone environment variable to the given option value.
159 Consult your operating system documentation for legal time zone
160 specification formats.
161
162· --user={user_name|user_id}
163
164 Run the mysqld server as the user having the name user_name or the numeric
165 user ID user_id. (“User” in this context refers to a system login account,
166 not a MySQL user listed in the grant tables.)
167
168
169If you execute mysqld_safe with the --defaults-file or --defaults-extra-option
170option to name an option file, the option must be the first one given on the
171command line or the option file will not be used. For example, this command
172will not use the named option file:
173
174 mysql> mysqld_safe --port=port_num --defaults-file=file_name
175
176Instead, use the following command:
177
178 mysql> mysqld_safe --defaults-file=file_name --port=port_num
179
180The mysqld_safe script is written so that it normally can start a server that
181was installed from either a source or a binary distribution of MySQL, even
182though these types of distributions typically install the server in slightly
183different locations. (See Section 4.6, “Installation Layouts”.) mysqld_safe
184expects one of the following conditions to be true:
185
186· The server and databases can be found relative to the working directory
187 (the directory from which mysqld_safe is invoked). For binary
188 distributions, mysqld_safe looks under its working directory for bin and
189 data directories. For source distributions, it looks for libexec and var
190 directories. This condition should be met if you execute mysqld_safe from
191 your MySQL installation directory (for example, /usr/local/mysql for a
192 binary distribution).
193
194· If the server and databases cannot be found relative to the working
195 directory, mysqld_safe attempts to locate them by absolute pathnames.
196 Typical locations are /usr/local/libexec and /usr/local/var. The actual
197 locations are determined from the values configured into the distribution
198 at the time it was built. They should be correct if MySQL is installed in
199 the location specified at configuration time.
200
201
202Because mysqld_safe tries to find the server and databases relative to its own
203working directory, you can install a binary distribution of MySQL anywhere, as
204long as you run mysqld_safe from the MySQL installation directory:
205
206 shell> cd mysql_installation_directory
207 shell> bin/mysqld_safe &
208
209If mysqld_safe fails, even when invoked from the MySQL installation directory,
210you can specify the --ledir and --datadir options to indicate the directories
211in which the server and databases are located on your system.
212
213Normally, you should not edit the mysqld_safe script. Instead, configure
215section of a my.cnf option file. In rare cases, it might be necessary to edit
217your modified version of mysqld_safe might be overwritten if you upgrade MySQL
218in the future, so you should make a copy of your edited version that you can
219reinstall.
220
221On NetWare, mysqld_safe is a NetWare Loadable Module (NLM) that is ported from
222the original Unix shell script. It starts the server as follows:
223
2241. Runs a number of system and option checks.
225
2262. Runs a check on MyISAM tables.
227
2283. Provides a screen presence for the MySQL server.
229
2304. Starts mysqld, monitors it, and restarts it if it terminates in error.
231
2325. Sends error messages from mysqld to the host_name.err file in the data
233 directory.
234
2356. Sends mysqld_safe screen output to the host_name.safe file in the data
236 directory.
237
239 Copyright 1997-2007 MySQL AB
240
241 This documentation is NOT distributed under a GPL license. Use of this
242 documentation is subject to the following terms: You may create a
243 printed copy of this documentation solely for your own personal use.
244 Conversion to other formats is allowed as long as the actual content is
245 not altered or edited in any way. You shall not publish or distribute
246 this documentation in any form or on any media, except if you
247 distribute the documentation in a manner similar to how MySQL
248 disseminates it (that is, electronically for download on a Web site
249 with the software) or on a CD-ROM or similar medium, provided however
250 that the documentation is disseminated together with the software on
251 the same medium. Any other use, such as any dissemination of printed
252 copies or use of this documentation, in whole or in part, in another
253 publication, requires the prior written consent from an authorized
254 representative of MySQL AB. MySQL AB reserves any and all rights to
255 this documentation not expressly granted above.
256
257 Please email <docs@mysql.com> for more information.
258
260 For more information, please refer to the MySQL Reference Manual, which
261 may already be installed locally and which is also available online at
262 http://dev.mysql.com/doc/.
263
265 MySQL AB (http://www.mysql.com/). This software comes with no
266 warranty.
267
268
269
270MySQL 5.0 07/04/2007 MYSQLD_SAFE(1)