Specifications

mysql> revoke alter, create, drop
-> on books.*
-> from sally;
And later, when she doesnt need to use the database any more, we can revoke her privileges
altogether:
mysql> revoke all
-> on books.*
-> from sally;
Setting Up a User for the Web
You will need to set up a user for your PHP scripts to connect to MySQL. Again we can apply
the privilege of least principle: What should the scripts be able to do?
In most cases theyll only need to SELECT, INSERT, DELETE, and UPDATE rows from tables. You
can set this up as follows:
mysql> grant select, insert, delete, update
-> on books.*
-> to bookorama identified by ‘bookorama123’;
Obviously, for security reasons, you should choose a better password than this.
If you use a Web hosting service, youll usually get access to the other user-type privileges on
a database they create for you. They will typically give you the same user_name and password
for command-line use (setting up tables and so on) and for Web script connections (querying
the database). This is marginally less secure. You can set up a user with this level of privilege
as follows:
mysql> grant select, insert, update, delete, index, alter, create, drop
-> on books.*
-> to bookorama identified by ‘bookorama123’;
Go ahead and set up this second user.
Logging Out As root
You can log out of the MySQL monitor by typing quit. You should log back in as your Web
user to test that everything is working correctly.
Using the Right Database
If youve reached this stage, you should be logged in to a user-level MySQL account ready to
test the example code, either because youve just set it up, or because your Web server admin-
istrator has set it up for you.
Creating Your Web Database
C
HAPTER 8
8
CREATING YOUR
WEB DATABASE
193
11 7842 CH08 3/6/01 3:38 PM Page 193