Saturday, January 17, 2004

Some basic mysql primer stuff

I've been learning mysql, and here is some basic mysql setup stuff...

MySQL works in a client server model. First we need to setup the server stuff. I am using Suse 9.0, and I had installed all the applications that can be installed during initial setup. Mysql was therefore installed by default. /etc/rc.d/mysql start, causes the mysql daemon to start up. It does its initializations and informs the admin to setup a root password. That can be done by
mysqladmin -u root password "password"
Having completed the above command one can login using the mysql client.
mysql -u root -p
The above command will cause mysqlclient to ask for a password, and then you are ready to go.
The next step was to grant my local username access to a table. I issued the following commands,
GRANT ALL ON weblog.* TO adnan@localhost IDENTIFIED BY "password_here"
GRANT ALL ON weblog.* TO adnan@% IDENTIFIED BY "password_here"

The first allows access to the user adnan from localhost and the second one grants access to adnan from any host. This is so I can login using a mysql client from any host at work.

Make sure the above is done as root.

Logging in again using mysql -u adnan -p, I issued the command,
create database weblog;

Using Select database(); you can view the currently selected database. use database_name causes database_name to be the current working database. Invoking the mysql client as,
mysql database_name
is the normal way of prespecifying the working database.

To create a table within a working database, the following syntax is used:
create table posts (
date DATE NOT NULL,
title VARCHAR(255),
text LONGBLOB
)

To view a tables columns use
describe posts;

To insert values into database use:
insert into posts values("2004-1-27", "First Post", "Here is a first post");

to view the values in a table, type
select * from table_name

To update an entry in a table,
update table_name set column=value where column_name = "Some Value";

Thats it for today... I thought I'd post this stuff for future reference.

Mozilla and hypocrisy

Right, but what about the experiences that Mozilla chooses to default for users like switching to  Yahoo and making that the default upon ...