Security Guidelines
560
control system that MySQL uses for setting up user accounts and checking database access, see
Section 6.2, “The MySQL Access Privilege System”
.
For answers to some questions that are often asked about MySQL Server security issues, see
Section B.9, “MySQL 5.0 FAQ: Security”
.
6.1.1. Security Guidelines
Anyone using MySQL on a computer connected to the Internet should read this section to avoid the
most common security mistakes.
In discussing security, it is necessary to consider fully protecting the entire server host (not just the
MySQL server) against all types of applicable attacks: eavesdropping, altering, playback, and denial of
service. We do not cover all aspects of availability and fault tolerance here.
MySQL uses security based on Access Control Lists (ACLs) for all connections, queries, and other
operations that users can attempt to perform. There is also support for SSL-encrypted connections
between MySQL clients and servers. Many of the concepts discussed here are not specific to MySQL
at all; the same general ideas apply to almost all applications.
When running MySQL, follow these guidelines:
• Do not ever give anyone (except MySQL
root
accounts) access to the
user
table in the
mysql
database! This is critical.
• Learn how the MySQL access privilege system works (see
Section 6.2, “The MySQL Access
Privilege System”
). Use the
GRANT
and
REVOKE
statements to control access to MySQL. Do not
grant more privileges than necessary. Never grant privileges to all hosts.
Checklist:
• Try
mysql -u root
. If you are able to connect successfully to the server without being asked
for a password, anyone can connect to your MySQL server as the MySQL
root
user with full
privileges! Review the MySQL installation instructions, paying particular attention to the information
about setting a
root
password. See
Section 2.18.2, “Securing the Initial MySQL Accounts”
.
• Use the
SHOW GRANTS
statement to check which accounts have access to what. Then use the
REVOKE
statement to remove those privileges that are not necessary.
• Do not store cleartext passwords in your database. If your computer becomes compromised,
the intruder can take the full list of passwords and use them. Instead, use
SHA1()
[956]
,
MD5()
[955]
, or some other one-way hashing function and store the hash value.
• Do not choose passwords from dictionaries. Special programs exist to break passwords. Even
passwords like “xfish98” are very bad. Much better is “duag98” which contains the same word
“fish” but typed one key to the left on a standard QWERTY keyboard. Another method is to use
a password that is taken from the first characters of each word in a sentence (for example, “Four
score and seven years ago” results in a password of “Fsasya”). The password is easy to remember
and type, but difficult to guess for someone who does not know the sentence. In this case, you can
additionally substitute digits for the number words to obtain the phrase “4 score and 7 years ago”,
yielding the password “4sa7ya” which is even more difficult to guess.
• Invest in a firewall. This protects you from at least 50% of all types of exploits in any software. Put
MySQL behind the firewall or in a demilitarized zone (DMZ).
Checklist:
• Try to scan your ports from the Internet using a tool such as
nmap
. MySQL uses port 3306
by default. This port should not be accessible from untrusted hosts. As a simple way to check
whether your MySQL port is open, try the following command from some remote machine, where
server_host
is the host name or IP address of the host on which your MySQL server runs:
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...