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.

294 Chapter 12 Advanced <strong>MySQL</strong> Administration<br />

privileges are stored, you can alter them manually.When you update them manually, the<br />

<strong>MySQL</strong> server will not notice that they have changed.<br />

You need to point out to the server that a change has occurred, <strong>and</strong> you can do this<br />

in three ways.You can type<br />

flush privileges;<br />

at the <strong>MySQL</strong> prompt (you need to be logged in as an administrator to use this comm<strong>and</strong>).This<br />

is the most commonly used way of updating the privileges.<br />

Alternatively, you can run either<br />

mysqladmin flush-privileges<br />

or<br />

mysqladmin reload<br />

from your operating system.<br />

After this, global-level privileges will be checked the next time a user connects; database<br />

privileges will be checked when the next use statement is issued; <strong>and</strong> table- <strong>and</strong><br />

column-level privileges will be checked on a user’s next request.<br />

Making Your <strong>MySQL</strong> Database Secure<br />

Security is important, especially when you begin connecting your <strong>MySQL</strong> database to<br />

your website.The following sections explain the precautions you ought to take to protect<br />

your database.<br />

<strong>MySQL</strong> from the Operating System’s Point of View<br />

Running the <strong>MySQL</strong> server (mysqld) as root is a bad idea if you are running a Unix-like<br />

operating system. Doing this gives a <strong>MySQL</strong> user with a full set of privileges the right to<br />

read <strong>and</strong> write files anywhere in the operating system.This is an important point, easily<br />

overlooked, which was famously used to hack Apache’s website. (Fortunately, the crackers<br />

were “white hats” [good guys], <strong>and</strong> their only action was to tighten up security.)<br />

Setting up a <strong>MySQL</strong> user specifically for the purpose of running mysqld is a good<br />

idea. In addition, you can then make the directories (where the physical data is stored)<br />

accessible only by the <strong>MySQL</strong> user. In many installations, the server is set up to run as<br />

userid mysql, in the mysql group.<br />

You should also ideally set up your <strong>MySQL</strong> server behind your firewall.This way, you<br />

can stop connections from unauthorized machines. Check to see whether you can connect<br />

from outside to your server on port number 3306.This is the default port <strong>MySQL</strong><br />

runs on <strong>and</strong> should be closed on your firewall.

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

Saved successfully!

Ooh no, something went wrong!