timothy@apple.com | f42518d | 2008-02-06 20:19:16 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <HTML |
| 3 | ><HEAD |
| 4 | ><TITLE |
| 5 | >MySQL</TITLE |
| 6 | ><META |
| 7 | NAME="GENERATOR" |
| 8 | CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK |
| 9 | REL="HOME" |
| 10 | TITLE="The Bugzilla Guide - 2.20.1 |
| 11 | Release" |
| 12 | HREF="index.html"><LINK |
| 13 | REL="UP" |
| 14 | TITLE="Bugzilla Security" |
| 15 | HREF="security.html"><LINK |
| 16 | REL="PREVIOUS" |
| 17 | TITLE="Operating System" |
| 18 | HREF="security-os.html"><LINK |
| 19 | REL="NEXT" |
| 20 | TITLE="Webserver" |
| 21 | HREF="security-webserver.html"></HEAD |
| 22 | ><BODY |
| 23 | CLASS="section" |
| 24 | BGCOLOR="#FFFFFF" |
| 25 | TEXT="#000000" |
| 26 | LINK="#0000FF" |
| 27 | VLINK="#840084" |
| 28 | ALINK="#0000FF" |
| 29 | ><DIV |
| 30 | CLASS="NAVHEADER" |
| 31 | ><TABLE |
| 32 | SUMMARY="Header navigation table" |
| 33 | WIDTH="100%" |
| 34 | BORDER="0" |
| 35 | CELLPADDING="0" |
| 36 | CELLSPACING="0" |
| 37 | ><TR |
| 38 | ><TH |
| 39 | COLSPAN="3" |
| 40 | ALIGN="center" |
| 41 | >The Bugzilla Guide - 2.20.1 |
| 42 | Release</TH |
| 43 | ></TR |
| 44 | ><TR |
| 45 | ><TD |
| 46 | WIDTH="10%" |
| 47 | ALIGN="left" |
| 48 | VALIGN="bottom" |
| 49 | ><A |
| 50 | HREF="security-os.html" |
| 51 | ACCESSKEY="P" |
| 52 | >Prev</A |
| 53 | ></TD |
| 54 | ><TD |
| 55 | WIDTH="80%" |
| 56 | ALIGN="center" |
| 57 | VALIGN="bottom" |
| 58 | >Chapter 4. Bugzilla Security</TD |
| 59 | ><TD |
| 60 | WIDTH="10%" |
| 61 | ALIGN="right" |
| 62 | VALIGN="bottom" |
| 63 | ><A |
| 64 | HREF="security-webserver.html" |
| 65 | ACCESSKEY="N" |
| 66 | >Next</A |
| 67 | ></TD |
| 68 | ></TR |
| 69 | ></TABLE |
| 70 | ><HR |
| 71 | ALIGN="LEFT" |
| 72 | WIDTH="100%"></DIV |
| 73 | ><DIV |
| 74 | CLASS="section" |
| 75 | ><H1 |
| 76 | CLASS="section" |
| 77 | ><A |
| 78 | NAME="security-mysql" |
| 79 | >4.2. MySQL</A |
| 80 | ></H1 |
| 81 | ><DIV |
| 82 | CLASS="section" |
| 83 | ><H2 |
| 84 | CLASS="section" |
| 85 | ><A |
| 86 | NAME="security-mysql-account" |
| 87 | >4.2.1. The MySQL System Account</A |
| 88 | ></H2 |
| 89 | ><P |
| 90 | >As mentioned in <A |
| 91 | HREF="security-os.html#security-os-accounts" |
| 92 | >Section 4.1.2</A |
| 93 | >, the MySQL |
| 94 | daemon should run as a non-privleged, unique user. Be sure to consult |
| 95 | the MySQL documentation or the documentation that came with your system |
| 96 | for instructions. |
| 97 | </P |
| 98 | ></DIV |
| 99 | ><DIV |
| 100 | CLASS="section" |
| 101 | ><H2 |
| 102 | CLASS="section" |
| 103 | ><A |
| 104 | NAME="security-mysql-root" |
| 105 | >4.2.2. The MySQL <SPAN |
| 106 | CLASS="QUOTE" |
| 107 | >"root"</SPAN |
| 108 | > and <SPAN |
| 109 | CLASS="QUOTE" |
| 110 | >"anonymous"</SPAN |
| 111 | > Users</A |
| 112 | ></H2 |
| 113 | ><P |
| 114 | >By default, MySQL comes with a <SPAN |
| 115 | CLASS="QUOTE" |
| 116 | >"root"</SPAN |
| 117 | > user with a |
| 118 | blank password and an <SPAN |
| 119 | CLASS="QUOTE" |
| 120 | >"anonymous"</SPAN |
| 121 | > user, also with a blank |
| 122 | password. In order to protect your data, the <SPAN |
| 123 | CLASS="QUOTE" |
| 124 | >"root"</SPAN |
| 125 | > user |
| 126 | should be given a password and the anonymous user should be disabled. |
| 127 | </P |
| 128 | ><DIV |
| 129 | CLASS="example" |
| 130 | ><A |
| 131 | NAME="security-mysql-account-root" |
| 132 | ></A |
| 133 | ><P |
| 134 | ><B |
| 135 | >Example 4-1. Assigning the MySQL <SPAN |
| 136 | CLASS="QUOTE" |
| 137 | >"root"</SPAN |
| 138 | > User a Password</B |
| 139 | ></P |
| 140 | ><TABLE |
| 141 | BORDER="0" |
| 142 | BGCOLOR="#E0E0E0" |
| 143 | WIDTH="100%" |
| 144 | ><TR |
| 145 | ><TD |
| 146 | ><FONT |
| 147 | COLOR="#000000" |
| 148 | ><PRE |
| 149 | CLASS="screen" |
| 150 | > <SAMP |
| 151 | CLASS="prompt" |
| 152 | >bash$</SAMP |
| 153 | > mysql mysql |
| 154 | <SAMP |
| 155 | CLASS="prompt" |
| 156 | >mysql></SAMP |
| 157 | > UPDATE user SET password = password('<VAR |
| 158 | CLASS="replaceable" |
| 159 | >new_password</VAR |
| 160 | >') WHERE user = 'root'; |
| 161 | <SAMP |
| 162 | CLASS="prompt" |
| 163 | >mysql></SAMP |
| 164 | > FLUSH PRIVILEGES; |
| 165 | </PRE |
| 166 | ></FONT |
| 167 | ></TD |
| 168 | ></TR |
| 169 | ></TABLE |
| 170 | ></DIV |
| 171 | ><DIV |
| 172 | CLASS="example" |
| 173 | ><A |
| 174 | NAME="security-mysql-account-anonymous" |
| 175 | ></A |
| 176 | ><P |
| 177 | ><B |
| 178 | >Example 4-2. Disabling the MySQL <SPAN |
| 179 | CLASS="QUOTE" |
| 180 | >"anonymous"</SPAN |
| 181 | > User</B |
| 182 | ></P |
| 183 | ><TABLE |
| 184 | BORDER="0" |
| 185 | BGCOLOR="#E0E0E0" |
| 186 | WIDTH="100%" |
| 187 | ><TR |
| 188 | ><TD |
| 189 | ><FONT |
| 190 | COLOR="#000000" |
| 191 | ><PRE |
| 192 | CLASS="screen" |
| 193 | > <SAMP |
| 194 | CLASS="prompt" |
| 195 | >bash$</SAMP |
| 196 | > mysql -u root -p mysql <A |
| 197 | NAME="security-mysql-account-anonymous-mysql" |
| 198 | ><IMG |
| 199 | SRC="../images/callouts/1.gif" |
| 200 | HSPACE="0" |
| 201 | VSPACE="0" |
| 202 | BORDER="0" |
| 203 | ALT="(1)"></A |
| 204 | > |
| 205 | <SAMP |
| 206 | CLASS="prompt" |
| 207 | >Enter Password:</SAMP |
| 208 | > <VAR |
| 209 | CLASS="replaceable" |
| 210 | >new_password</VAR |
| 211 | > |
| 212 | <SAMP |
| 213 | CLASS="prompt" |
| 214 | >mysql></SAMP |
| 215 | > DELETE FROM user WHERE user = ''; |
| 216 | <SAMP |
| 217 | CLASS="prompt" |
| 218 | >mysql></SAMP |
| 219 | > FLUSH PRIVILEGES; |
| 220 | </PRE |
| 221 | ></FONT |
| 222 | ></TD |
| 223 | ></TR |
| 224 | ></TABLE |
| 225 | ><DIV |
| 226 | CLASS="calloutlist" |
| 227 | ><DL |
| 228 | COMPACT="COMPACT" |
| 229 | ><DT |
| 230 | ><A |
| 231 | HREF="security-mysql.html#security-mysql-account-anonymous-mysql" |
| 232 | ><IMG |
| 233 | SRC="../images/callouts/1.gif" |
| 234 | HSPACE="0" |
| 235 | VSPACE="0" |
| 236 | BORDER="0" |
| 237 | ALT="(1)"></A |
| 238 | ></DT |
| 239 | ><DD |
| 240 | >This command assumes that you have already completed |
| 241 | <A |
| 242 | HREF="security-mysql.html#security-mysql-account-root" |
| 243 | >Example 4-1</A |
| 244 | >. |
| 245 | </DD |
| 246 | ></DL |
| 247 | ></DIV |
| 248 | ></DIV |
| 249 | ></DIV |
| 250 | ><DIV |
| 251 | CLASS="section" |
| 252 | ><H2 |
| 253 | CLASS="section" |
| 254 | ><A |
| 255 | NAME="security-mysql-network" |
| 256 | >4.2.3. Network Access</A |
| 257 | ></H2 |
| 258 | ><P |
| 259 | >If MySQL and your webserver both run on the same machine and you |
| 260 | have no other reason to access MySQL remotely, then you should disable |
| 261 | the network access. This, along with the suggestion in |
| 262 | <A |
| 263 | HREF="security-os.html#security-os-ports" |
| 264 | >Section 4.1.1</A |
| 265 | >, will help protect your system from |
| 266 | any remote vulnerabilites in MySQL. |
| 267 | </P |
| 268 | ><DIV |
| 269 | CLASS="example" |
| 270 | ><A |
| 271 | NAME="security-mysql-network-ex" |
| 272 | ></A |
| 273 | ><P |
| 274 | ><B |
| 275 | >Example 4-3. Disabling Networking in MySQL</B |
| 276 | ></P |
| 277 | ><P |
| 278 | >Simply enter the following in <TT |
| 279 | CLASS="filename" |
| 280 | >/etc/my.conf</TT |
| 281 | >: |
| 282 | <TABLE |
| 283 | BORDER="0" |
| 284 | BGCOLOR="#E0E0E0" |
| 285 | WIDTH="100%" |
| 286 | ><TR |
| 287 | ><TD |
| 288 | ><FONT |
| 289 | COLOR="#000000" |
| 290 | ><PRE |
| 291 | CLASS="screen" |
| 292 | > [myslqd] |
| 293 | # Prevent network access to MySQL. |
| 294 | skip-networking |
| 295 | </PRE |
| 296 | ></FONT |
| 297 | ></TD |
| 298 | ></TR |
| 299 | ></TABLE |
| 300 | > |
| 301 | </P |
| 302 | ></DIV |
| 303 | ></DIV |
| 304 | ></DIV |
| 305 | ><DIV |
| 306 | CLASS="NAVFOOTER" |
| 307 | ><HR |
| 308 | ALIGN="LEFT" |
| 309 | WIDTH="100%"><TABLE |
| 310 | SUMMARY="Footer navigation table" |
| 311 | WIDTH="100%" |
| 312 | BORDER="0" |
| 313 | CELLPADDING="0" |
| 314 | CELLSPACING="0" |
| 315 | ><TR |
| 316 | ><TD |
| 317 | WIDTH="33%" |
| 318 | ALIGN="left" |
| 319 | VALIGN="top" |
| 320 | ><A |
| 321 | HREF="security-os.html" |
| 322 | ACCESSKEY="P" |
| 323 | >Prev</A |
| 324 | ></TD |
| 325 | ><TD |
| 326 | WIDTH="34%" |
| 327 | ALIGN="center" |
| 328 | VALIGN="top" |
| 329 | ><A |
| 330 | HREF="index.html" |
| 331 | ACCESSKEY="H" |
| 332 | >Home</A |
| 333 | ></TD |
| 334 | ><TD |
| 335 | WIDTH="33%" |
| 336 | ALIGN="right" |
| 337 | VALIGN="top" |
| 338 | ><A |
| 339 | HREF="security-webserver.html" |
| 340 | ACCESSKEY="N" |
| 341 | >Next</A |
| 342 | ></TD |
| 343 | ></TR |
| 344 | ><TR |
| 345 | ><TD |
| 346 | WIDTH="33%" |
| 347 | ALIGN="left" |
| 348 | VALIGN="top" |
| 349 | >Operating System</TD |
| 350 | ><TD |
| 351 | WIDTH="34%" |
| 352 | ALIGN="center" |
| 353 | VALIGN="top" |
| 354 | ><A |
| 355 | HREF="security.html" |
| 356 | ACCESSKEY="U" |
| 357 | >Up</A |
| 358 | ></TD |
| 359 | ><TD |
| 360 | WIDTH="33%" |
| 361 | ALIGN="right" |
| 362 | VALIGN="top" |
| 363 | >Webserver</TD |
| 364 | ></TR |
| 365 | ></TABLE |
| 366 | ></DIV |
| 367 | ></BODY |
| 368 | ></HTML |
| 369 | > |