13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Database Server Security<br />

383<br />

n<br />

Look for services that offer trial periods, money-back guarantees, or some other<br />

way of seeing firsth<strong>and</strong> how your web applications will run before committing to<br />

using them for a longer period of time.<br />

Database Server Security<br />

In addition to keeping all of our software up-to-date, we can do a few things to keep<br />

our databases more secure as well. Again, although a complete treatment of security<br />

would require a full book for each of the database servers against which we might write<br />

our web applications, we will give some general strategies here to which we should all<br />

pay attention.<br />

Users <strong>and</strong> the Permissions System<br />

Spend the time to get to know the authentication <strong>and</strong> permissions system of the database<br />

server that you have chosen to use. A surprising number of database attacks succeed<br />

simply because people have not taken the time to make sure this system is secure.<br />

Make sure that all accounts have passwords. One of the first things you do with any<br />

database server is make sure that the database super user (root) has a password. Ensure<br />

that these passwords do not contain words that are from the dictionary. Even passwords<br />

such as 44horseA are much less secure than passwords like FI93!!xl2@. For those worried<br />

about the ease with which passwords can be memorized, consider using the first letter of<br />

all the words in a particular sentence, with some pattern of capitalization, such as<br />

IwTbOtIwTwOt, from “It was the best of times, it was the worst of times” (A Tale of Two<br />

Cities, by Charles Dickens).<br />

Many databases (including older versions of <strong>MySQL</strong>) will be installed with an anonymous<br />

user with more privileges than you would probably like.While investigating <strong>and</strong><br />

becoming comfortable with the permissions system, make sure that any default accounts<br />

do exactly what you want them to do, <strong>and</strong> remove those that do not.<br />

Make sure that only the super-user account has access to the permissions tables <strong>and</strong><br />

administrative databases. Other accounts should have only permissions to access or modify<br />

strictly those databases or tables they need.<br />

To test it out, try the following, <strong>and</strong> verify that an error occurs:<br />

n Connect without specifying a username <strong>and</strong> password.<br />

n Connect as root without specifying a password.<br />

n Give an incorrect password for root.<br />

n Connect as a user <strong>and</strong> try to access a table for which the user should not have permission.<br />

n Connect as a user <strong>and</strong> try to access system databases or permissions tables.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!