stablevalue.com a blog on stock market and things of interest
Articles

Installing Postgres SQL Database

Posted by btr Sun, 04 Jul 2004 02:28:35 GMT

Here’re the steps to install a Postgres SQL database on RedHat 9.0.

  1. login as root
  2. su postgres
  3. mkdir /home/db
  4. chown postgres /home/db and chgrp postgres /home/db
  5. export PGDATA=/home/db
  6. initdb The files belonging to this database system will be owned by user “postgres”. This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8. This locale setting will prevent the use of indexes for pattern matching operations. If that is a concern, rerun initdb with the collation order set to “C”. For more information see the Administrator’s Guide.

Fixing permissions on existing directory /home/db… ok creating directory /home/db/base… ok creating directory /home/db/global… ok creating directory /home/db/pg_xlog… ok creating directory /home/db/pg_clog… ok creating template1 database in /home/db/base/1… ok creating configuration files… ok initializing pg_shadow… ok enabling unlimited row size for system tables… ok initializing pg_depend… ok creating system views… ok loading pg_description… ok creating conversions… ok setting privileges on built-in objects… ok vacuuming database template1… ok copying template1 to template0… ok

Success. You can now start the database server using:

/usr/bin/postmaster -D /home/db

or /usr/bin/pg_ctl -D /home/db -l logfile start

  1. /usr/bin/pg_ctl -D /home/db -l logfile start

bash-2.05b$ /usr/bin/pg_ctl -D /home/db -l logfile start postmaster successfully started

bash-2.05b$ createdb test CREATE DATABASE

bash-2.05b$ psql test Welcome to psql 7.3.2, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit

test=#

test=# CREATE TABLE films ( test(# code char(5) CONSTRAINT firstkey PRIMARY KEY, test(# title varchar(40) NOT NULL, test(# did integer NOT NULL, test(# date_prod date, test(# kind varchar(10), test(# len interval hour to minute test(# ); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index ‘firstkey’ for table ‘films’ CREATE TABLE

test=# INSERT INTO films (code, title, did, date_prod, kind) test-# VALUES (‘T_601’, ‘Yojimbo’, 106, DEFAULT, ‘Drama’); INSERT 16981 1

test=# select * from films; code | title | did | date_prod | kind | len ——-+———+—–+———–+——-+—– T_601 | Yojimbo | 106 | | Drama | (1 row)

bash-2.05b$ pg_ctl -D /home/db stop waiting for postmaster to shut down……done postmaster successfully shut down

starting it with networking

bash-2.05b$ pg_ctl -D /home/db -l logfile -o -i start postmaster successfully started

bash-2.05b$ psql test Welcome to psql 7.3.2, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit

test=# create user tester with password ‘tester’; CREATE USER

create table for mono test

test=# CREATE TABLE “test” ( test(# “person” character varying(256) NOT NULL, test(# “email” character varying(256) NOT NULL test(# ); CREATE TABLE test=# insert into test (person, email) values(‘user1’,’users@nomail.com’); INSERT 16984 1 test=# insert into test (person, email) values(‘user2’,’user2@nomail.com’); INSERT 16985 1 test=# select * from test; person | email ——–+—————— user1 | users@nomail.com user2 | user2@nomail.com (2 rows)

I got this error

Npgsql.NpgsqlException: No pg_hba.conf entry for host 127.0.0.1, user tester, database tester Severity: FATAL in <0x00061> Npgsql.NpgsqlConnection:CheckErrors () in <0x0004f> (wrapper remoting-invoke-with-check) Npgsql.NpgsqlConnection:CheckErrors () in <0x00447> Npgsql.NpgsqlConnection:Open ()

Well, the database name should be test, but it reported “tester”. I don’t know why. I’m testing dbpage1.aspx.

OK, I added a record in pg_hba.conf to allow host from 127.0.0.1 to connect to the database, but got this error instead

Npgsql.NpgsqlException: Database “tester” does not exist in the system catalog. Severity: FATAL

It still thinks the database is “tester”. I need to check the connect string one more time and will shutdown Apache to see if it changes anything.

While waiting for reboot, I downloaded pgadmin, a GUI program for managing Postgres database. Nice!

Finally, I got it running on dbpage1.aspx and dbpage2.aspx. It turned out that the connect string was wrong. The original connect string was “sever=127.0.0.1;user id=tester;password=tester;dbname=test”. The correct string should be using “database=test”!

Don’t forget granting permission to the tester on the database test!

Here’s the dbpage1.aspx sample.

Posted in  | 1 comment

Comments

Comments are disabled

Market News And Commentaries
Updated at Sat Dec 31 01:25:01 -0500 2011
Market Week in Review

more

Source: BETWEEN THE HEDGES
Airline Stocks: Airlines tumble 31% in 2011; outlook cloudy

Airline stocks are set to end 2011 in the red as withering demand and soaring jet fuel prices squeezed the industry’s profits. For 2012, the environment is expected to be just as challenging. more

Source: MarketWatch.com - Top Stories
Building Your Financial Dream Team

With stock markets volatile, tax rates uncertain and estate laws facing review next year, these are challenging times for financial advisers, accountants and lawyers. Are yours making the grade? more

Source: WSJ.com: Markets
Out of the Money Calendar Spreads

This is a guest post by Derek Devore, an experienced options trader. Find out more about his OptionBoost Video Training Program at http://optionboost.com One of my favorite structures when I’m evaluating a position which is slow moving, but is on its way to reaching a particular price point, i more

Source: StockTickr Trading Journal Blog
Disasters and demand slowdown hit Asia

The region’s markets fell this year as investors struggled to cope with natural disasters and slowing demand from Europe and the US more

Source: Asia Pacific Equities Market Data - FT.com
Foreclosures: Next shoe to drop for banks?

Bank stocks have been shellacked lately as investors worry about what impact the foreclosure scandal will have on the results for the nation's largest financial institutions. more

Source: Market, personal finance, media, and technology expert commentary - CNNMoney.com
Go forth, open the mind and just walk

Walking has taught Christopher Caldwell that impossible-looking tasks can be carried out by breaking them down into small steps more

Source: Financial Times - Comment
Groupon (GRPN) Files For IPO As Another Tech Bubble Looms

The IPO market is really beginning to catch fire with the tech industry partying like it’s 1999.  The party lights glowed and the DJ began spinning the beats before the LinkedIn (LNKD) IPO a couple weeks ago and the party will continue reaching a feverish pitch with a Groupon (GRPN) IPO.  more

Source: SelfInvestors | ETFs, IPOs & Breakout Stocks
Charity: Water Donation and Happy New Year!

Back on December 1st I announced my Social for Charity effort in which I would donate $1 to Charity: Water for every comment, tweet, Facebook like, or Google made on StockTradingToGo during the month of December. This also included new Facebook fans. With December coming to a close, the results are more

Source: Stock Trading To Go
ROCKY YEAR ENDS FLAT

It's been one of the most volatile year in the stock market in recent memory, but you wouldn't know it by looking at the S&P 500. more

Source: Business and financial news - CNNMoney.com
Links for 2011-09-27 [del.icio.us]

more

Source: Maoxian
2011 was a disastrous year for Asian markets, with Japan down 18%, China -20% and India off 24% on average. What will the New Year bring? Well, to kick things off, investors will finally have an opportunity next week to see how a fully staffed market reacts to Korea's new leader, as well as increasing signs of a slowing Chinese economy ahead. (video)

2011 was a disastrous year for Asian markets, with Japan down 18%, China -20% and India off 24% on average. What will the New Year bring? Well, to kick things off, investors will finally have an opportunity next week to see how a fully staffed market reacts to Korea's new leader, as well as increasi more

Source: SeekingAlpha.com: SA Currents
How To Maintain An Optimal State

No matter what the market conditions may be, especially in weeks like this, it is very good idea to do everything you can to stick to the normal trading routine. While none of us can control what the markets do, we can control what we do everyday to be in the right place at the [...] more

Source: The Kirk Report