Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MySQL

Posted Oct 1, 1999

Setting Up a MySQL Based Website - Part I - Page 3

By DatabaseJournal.com Staff

by Andrew Chen


Setting up the Database

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 types. 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 tool.

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:

mysql -uroot -e"insert into host(Host,Db) values('localhost','guestbook')" mysql

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,
website char(255),
comments blob,
time int(10) unsigned
);" guestbook

Now that you`ve finished creating users and tables, create the perl application for accessing and adding to the database.


Page 4: Writing the Perl Application




MySQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MySQL Forum
Topic By Replies Updated
MySQL in high availability and transction secure banking application klamor 1 August 28th, 10:24 AM
MySQL rollback UAL225 1 August 28th, 10:15 AM
Browsing a DB file that uses MySql finleytech 1 July 26th, 10:51 AM
php cookie won't pass variable to next page ITdevGirl 0 June 22nd, 12:13 PM


















Thanks for your registration, follow us on our social networks to keep up-to-date