Setting Up a MySQL Based Website - Part I - page 3
In order for us to have a place
to store our guest book information, we
must create a properly configured database.
Within a database is a table. In the table,
there are columns that define the names and data
Although MySQL can have multiple tables within
a single database, for our purposes we will
use only one.
MySQL database uses the term 'columns` to
describe each individual field in a table.
To setup our database, we use the
mysqladmin -uroot create guestbook
will create our database for the guestbook. Since MySQL employs a user access system, we must tell MySQL who has access to which databases. Several commands need to be executed to setup the permissions:
-e"insert into host(Host,Db)
mysql -uroot -e"insert into db(Host,Db,User,Select_priv,Insert_priv) values('%','guestbook','guestbook','Y','Y')" mysql
mysql -uroot -e"insert into user(Host,User,Password) values('localhost','guestbook',password('guestbook')" mysql
mysqladmin -uroot reload
What the first statement tells MySQL, is to allow anyone from localhost access the database guestbook. The second statement says allow the user accessing guestbook from any host to SELECT and INSERT into the database. The third statement sets the user guestbook access from localhost, using the password guestbook. We call the function password() for guestbook in order to encrypt the password. The last statement tells MySQL to reload the user files.
The final step of MySQL configuration is to create the table to hold all our guestbook entries. To do this, we can execute:
mysql -uroot -e" CREATE TABLE guestbook (name char(255) not null,
age int(3) unsigned,
email char(255) not null,
time int(10) unsigned
Now that you`ve finished creating users and tables, create the perl application for accessing and adding to the database.
Sponsored by BlackBerry
BlackBerry® Enterprise Server Express enables businesses of any size to quickly and easily get started with the BlackBerry solution. It provides advanced BlackBerry smartphone features with no additional software or user license fees, and works with any Internet-enabled BlackBerry data plan or a BlackBerry enterprise data plan. Download now!