Search the MySQL manual:

4.2.2 How to Make MySQL Secure Against Crackers

When you connect to a MySQL server, you normally should use a password. The password is not transmitted in clear text over the connection, however the encryption algorithm is not very strong, and with some effort a clever attacker can crack the password if he is able to sniff the traffic between the client and the server. If the connection between the client and the server goes through an untrusted network, you should use an SSH tunnel to encrypt the communication.

All other information is transferred as text that can be read by anyone who is able to watch the connection. If you are concerned about this, you can use the compressed protocol (in MySQL Version 3.22 and above) to make things much harder. To make things even more secure you should use ssh. You can find an Open Source ssh client at http://www.openssh.org/, and a commercial ssh client at http://www.ssh.com/. With this, you can get an encrypted TCP/IP connection between a MySQL server and a MySQL client.

If you are using MySQL 4.0, you can also use internal OpenSSL support. See section 4.3.9 Using Secure Connections.

To make a MySQL system secure, you should strongly consider the following suggestions:

User Comments

Posted by [name withheld] on Tuesday January 29 2002, @8:30am[Delete] [Edit]

It really should be pointed out that running mysqld as nobody is almost
as bad as running it as root. Toss in e.g. apache run as nobody and
anyone who can execute CGI programs can do whatever he wants to
your database. Hooray.

Posted by shimi on Tuesday January 29 2002, @8:30am[Delete] [Edit]

When sorting rows containing hebrew (and perhaps
some other languages who doesn't use english
characters) - hebrew is not sorted at all.
Moreover, when mixed with English rows, the
English goes out fine, while in the middle of it
are some Hebrew rows (unsorted), some more
English rows, again some Hebrew rows (again
unsorted) and so on and so on.

Nothing on the manual here as it appears. If
someone else encountered that and knows of a
workaround, I'll be glad. :-)

The field type is "text" b.t.w.

The command I am using (in php) is:
$query = mysql_query("select * from friends order
by nickname") or die(mysql_error());
while(@($r = mysql_fetch_array($query))) {

I stand to be corrected. :>

Posted by Colin Reynolds on Tuesday January 29 2002, @8:30am[Delete] [Edit]

I feel that the final comment on this page is
inappropriate and serves only to confuse the new
user, since indexes have not yet been introduced.
Also, if the "menagerie" database is no
longer used from this point on, it would make
sense to demonstrate how to remove it at this
point (DROP DATABASE menagerie"?).

Posted by merlin on Tuesday January 29 2002, @8:30am[Delete] [Edit]

How about being able to configure the Ip address
that mysql listens on. Would be very nice for
multihomed MySQL hosts don't you think?

For example, how about a situation in which each
box in a server
cluster is directly connected to the Internet,
with a second network
set up for intra-cluster communications that isn't
connected to the
Internet ... why expose MySQL directly to the
Internet. then?

Posted by [name withheld] on Wednesday December 18 2002, @5:28pm[Delete] [Edit]

That's what the following option to mysqld is
for:
--bind-address=IP Ip address to bind to
which can be entered into my.cnf as
follows:
[mysqld]
bind-address=192.168.1.1
or similar.

Posted by Ranjit Singh on Friday February 28 2003, @9:13am[Delete] [Edit]

Having run through the post-install, I have found that the root user has two entries; one for localhost, and one for localhost.localdomain, which is left with a blank password.

As such, a user at the machine can log into the db as root by passing -h localhost.localdomain. By using the UPDATE user.. WHERE user='root' above, you set the password for both entries.

Posted by [name withheld] on Wednesday March 5 2003, @10:42pm[Delete] [Edit]

If you run "UPDATE user SET Password=PASSWORD('new_password') ..." from a UNIX MySQL shell then it will put that exact command -including cleartext password- in your ~/.mysql_history file.

Be sure to remove it when you exit mysql. The command "cat /dev/null > ~/.mysql_history" is overkill, but works great.

Add your own comment.