Apr 27 2010

Install Postgresql and pgadmin3 in Ubuntu

분류: Database, PostgreSQL, Server최 태현 @ 6:21 오후

PostgreSQL 8.2 version will be installed in Ubuntu 7.10 (Gutsy Gibbon)

sudo apt-get install postgresql-8.2 postgresql-client-8.2 postgresql-contrib-8.2

sudo apt-get install pgadmin3

This will install the database server/client, some extra utility scripts and the pgAdmin GUI application for working with the database.

Configuring postgresql in Ubuntu

Now we need to reset the password for the ‘postgres’ admin account for the server

sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD ‘password’;
template1=# \q

That alters the password for within the database, now we need to do the same for the unix user ‘postgres’:

sudo passwd -d postgres

sudo su postgres -c passwd

Now enter the same password that you used previously.

from here on in we can use both pgAdmin and command-line access (as the postgres user) to run the database server. But before you jump into pgAdmin we should set-up the PostgreSQL admin pack that enables better logging and monitoring within pgAdmin. Run the following at the command-line

we need to open up the server so that we can access and use it remotely - unless you only want to access the database on the local machine. To do this, first, we need to edit the postgresql.conf file:

sudo gedit /etc/postgresql/8.2/main/postgresql.conf

Now, to edit a couple of lines in the ‘Connections and Authentication’ section

Change the line

#listen_addresses = ‘localhost’

to

listen_addresses = ‘*’

and also change the line

#password_encryption = on

to

password_encryption = on

Then save the file and close gedit.

Now for the final step, we must define who can access the server. This is all done using the pg_hba.conf file.

sudo gedit /etc/postgresql/8.2/main/pg_hba.conf

Comment out, or delete the current contents of the file, then add this text to the bottom of the file

DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local all postgres ident sameuser
# TYPE DATABASE USER CIDR-ADDRESS METHOD

# “local” is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5

# Connections for all PCs on the subnet
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host all all [ip address] [subnet mask] md5

and in the last line, add in your subnet mask (i.e. 255.255.255.0) and the IP address of the machine that you would like to access your server (i.e. 138.250.192.115). However, if you would like to enable access to a range of IP addresses, just substitute the last number for a zero and all machines within that range will be allowed access (i.e. 138.250.192.0 would allow all machines with an IP address 138.250.192.x to use the database server).

That’s it, now all you have to do is restart the server

sudo /etc/init.d/postgresql-8.2 restart

That’s it you can start using postgresql in Ubuntu

Create a Database from command line

You can also use pgadmin3 for all postgresql related

To create a database with a user that have full rights on the database, use the following command

sudo -u postgres createuser -D -A -P mynewuser

sudo -u postgres createdb -O mynewuser mydatabase


Apr 22 2010

phpPgAdmin 사용하기

분류: .Mac, Database, How to, PHP, PostgreSQL최 태현 @ 5:50 오후

If your PostgreSQL server is running on the same server as the webserver, phpPgAdmin’s default configuration will work “out-of-the-box”; if not, you’ll need to edit the configuration file located at conf/config.inc.php. It should be self-explanatory. There’s also a “backup” copy of the installation file “conf/config.inc.php-dist“.

One problem which occurs quite often is the error message “Login disallowed for security reasons“, which occurs when trying to login as a user with an empty password, a common situation on (presumably well-protected) development machines. To enable this kind of login, set the option $conf['owned_only'] in conf/config.inc.php to true.

‘extra_login_security’ =

If extra login security is true, then logins via phpPgAdmin with no password or certain usernames (pgsql, postgres, root, administrator)
will be denied.


Apr 08 2010

Mac OS X Snow Leopard : PHP + OCI8

분류: .Mac, Apache2, Oracle, PHP, Server최 태현 @ 10:55 오전

Mac OS X Snow Leopard 에서 Oracle 10.g 설치하기 를 통해 Oracle을 설치했다는 전제하에 PHP에 OCI8을 설치하는 방법입니다.

먼저 OCI8 module이 제대로 설치되어 있는지 확인합니다.

env  |  grep  -­E  ”(ORACLE)|(DYLD)”

ORACLE_SID=y2love
ORACLE_BASE=/Users/Y2Love
DYLD_LIBRARY_PATH=/Users/oracle/oracle/product/10.2.0/db_1/lib
ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1

와 같이 나오면 됩니다.

Continue reading “Mac OS X Snow Leopard : PHP + OCI8″


Apr 08 2010

Mac OS X Snow Leopard 에서 Oracle 10.g 설치하기

분류: .Mac, How to, Oracle최 태현 @ 12:29 오전

1996년인가  대전광역시 중소기업지원정보시스템 구축사업을 하면서 대전광역시에 오라클을 처음으로 도입했었습니다.

그당시 Ingres DB가 행정망용으로 사용되고 있었는데  Sun Enterprise 에 오라클 DB를 올렸던 기억이 납니다. 그 당시만해도

오라클사에서는 도입만해줘도 무슨 요구든지 들어줬는데 지금은 너무 배짱을 부리는것 같습니다. 유지보수비가 장난이 아니더군요. 그것도 유지보수계약 체결하기 전까지의 모든 비용을 요구하면서… 입맛이 씁쓸합니다.

물론 1998년인가 1999년도에 대전광역시에 시정도우미 라는 내부 인트라넷 서비스를 만들면서 Linux ( 당시 알짜 리눅스 였던것 같은데..)에 MySQL, PHP 를 386PC에 설치하면서 Free Software로 방향을 전환했습니다.

오째든 장난삼아 Oracle을 MacBook에 올려봤습니다.

( 원문 Site 입니다.     ray_apps_blog )

Continue reading “Mac OS X Snow Leopard 에서 Oracle 10.g 설치하기”


Jan 09 2010

WorkBench에서 Encoding 변환해서 보기

분류: Database, mysql최 태현 @ 12:21 오전

SQL Editor에서 한글이 깨질경우 다음과 같이 화면 encoding을 변환해서 실행한다.

SET NAMES ‘euckr’;


Jan 08 2010

신성동 작은도서관 DB 분석

분류: Database, mysql최 태현 @ 12:47 오전

책갈피 프로그램이 MySQL DB를 사용하고 있어서 Dump를 받아왔는데 latin-1으로 charset이 되어 있어서 utf-8로 전환하였다.

다른 방법도 있겠지만 Dump를 받아온것이라 vim 을 통해 간단히 전환했다.

일단 vim으로 euc-kr로 인코딩되어 있는 dump 파일을 Loading 하면  문자가 깨져 보일것이다. 이때 다음과 같이 인코딩을 바꾸면 제대로 보인다.

:e ++enc=euc-kr

이 상태에서 인코딩을 바꿔서 저장하려면

:set fileencoding=utf-8

이렇게 하면 간단히 문자 인코딩을 변경할 수 있다.

이상태에서 다음과 같이 Dump File을 DB로 올려봤지만 …..

mysql -u root -p slibrary < sinsung.sql

ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes.

위와 같은 메시지가 나오면서 설치가 중단되는데,  그 이유는 mysql 이 key 의 길이를 1000바이트로 제한하기 때문이다.

mysql 측에서는 이걸 버그라 보지 않고 “제한”이라고 봐서 당분간은 처리할 용의가 없답니다.

latin-1 에서는 1글자가 1바이트이지만 utf-8 에서는 한글자가 3바이트이기 때문에 크기 계산에 주의해야 한다.

latin1 = 1 byte  = 1 chararcter
uft8    = 3 byte = 1 chararcter

즉, varchar(255)에서 255는 255 “바이트”가 아니라 “글자”이기 때문이다. utf-8일 경우 한글은 한 글자당 3바이트이므로 255 * 3 * 2 > 1000 이다.

해결방법은

CREATE TABLE bookadd_tbl (
S_ID varchar(20) NOT NULL default ”,
ADD_SEQ varchar(14) NOT NULL default ”,
ADD_NM1 varchar(200) default NULL,
ADD_AUTH varchar(128) default NULL,
ADD_CHUL varchar(128) default NULL,
ADD_YEAR varchar(60) default NULL,
ADD_TYPE varchar(100) default NULL,
ADD_LENGTH varchar(100) default NULL,
ADD_PAGE varchar(100) default NULL,
ADD_ETC varchar(255) default NULL,
ADD_DATE varchar(24) default NULL,
ADD_MARC longtext,
PRIMARY KEY  (S_ID,ADD_SEQ),
KEY ADD_TYPE (ADD_TYPE),
KEY ADD_NM1 (ADD_NM1,ADD_AUTH,ADD_CHUL)
) TYPE=MyISAM;

에서 TYPE… 부분을 ENGINE=InnoDB DEFAULT CHARSET=utf8 로 하면 된다.

왜 되는지는 정확히 모르겠다.


Nov 13 2009

Oracle SQL Developer 설치하기

분류: Database, How to, Ubuntu최 태현 @ 11:38 오전

Oracle SQL Developer is a free SQL development environment from Oracle. It provides a graphical tool to interact with your database. Furthermore, it is a complete standalone application thus neither SQL*Plus or Oracle Database Client software need to be installed beforehand in order to use it.

It does however, require that the Sun Java 6 JDK be installed on your system. Install it by typing:
sudo apt-get install sun-java6-jdk

Note:
You may also use OpenJDK

To obtain the installable package, navigate to Oracle’s SQL Developer download page at:
http://www.oracle.com/technology/software/products/sql/index.html

You must agree to the OTN License Agreement for SQL Developer in order to download the software. Once doing so, choose the Accept License Agreement radio button.

Scroll down and select the package entitled ‘Oracle SQL Developer RPM for Linux’ to download the package.

Note:
If you do not have an account with the Oracle Technology Network, go ahead and create one. It’s free and also required in order to download the package.

Next we will convert the .rpm to a .deb to install it in Ubuntu. We’ll do this by using an application called ‘alien’. Install it by typing:
sudo apt-get install alien

Next, navigate to where you saved the SQL Developer .rpm package and type:
sudo alien -k –scripts sqldeveloper*.rpm

This will create a .deb package ready to be installed into our system. We do so by typing:
sudo dpkg -i sqldeveloper*.deb

Oracle SQL Developer is now installed. However, in order to run it, we need to point it to the JDK. Failure to do so, will result in the following message when trying to run Oracle SQL Developer:

Oracle SQL Developer
Copyright (c) 2008, Oracle. All rights reserved.

Type the full pathname of a J2SE installation (or Ctrl-C to quit), the path will be stored in ~/.sqldeveloper/jdk

Looking at the message we can see that it’s trying to obtain the JDK path by reading a file called ‘jdk’ in a directory called ‘~/.sqldeveloper’. Let’s resolve this dependency.

First we’ll create the missing directory by typing:
mkdir -p ~/.sqldeveloper

Next we’ll create an empty jdk file by typing:
touch ~/.sqldeveloper/jdk

Edit this file and input the path to the JDK by typing:
gedit ~/.sqldeveloper/jdk
and pasting into it:
/usr/lib/jvm/java-6-sun

You may now run Oracle SQL Developer by typing:
sqldeveloper
Or by going to:
Applications > Programming > SQL Developer

You may also go ahead and delete the .rpm downloaded and subsequent .deb that was created.

Tags: , ,


Jun 12 2009

Oracle xe 환경설정하기(Tora 접속방법)

분류: Database, How to, Ubuntu최 태현 @ 4:21 오전
  1. Go to the following directory:

    /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin

  2. Look for the following scripts:
    • oracle_env.csh (for C or tcsh shell)
    • oracle_env.sh (for Bourne, Bash, or Korn shell)
  3. Run the appropriate script for your shell. For example:
    • Bourne, Bash, or Korn shell:
      $ . ./oracle_env.sh
    • C or tcsh shell:
      % source oracle_env.csh

You may also want edit your login or profile files so that these environment variables are set properly each time you log in or open a new shell.

For Bourne, Bash, or Korn shell, enter the following line into the .bash_profile (to log in) or .bashrc file (to open a new shell):

. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

For C or tcsh shell, enter the following line into the .login file (to log in) or .cshrc file (to open a new shell):

source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.csh

Tags: ,


Jun 12 2009

Oracle 접속오류 해결방법

분류: Database, How to최 태현 @ 1:47 오전

Why I got ORA-27121: unable to determine size of
shared memory segment ?

A. The full erros stack:
ERROR:
ORA-01034: ORACLE not available
ORA-27121: unable to determine size of shared memory
segment
Linux Error: 13: Permission denied

This is caused by Oracle installer not setting setuid
on $ORACLE_HOME/bin/oracle.

To fix do:
$ cd $ORACLE_HOME/bin
$ chmod 6751 oracle

Tags: , ,


Jun 11 2009

Tora With Oracle, MySQL

분류: Database, Desktop, How to최 태현 @ 9:54 오후

The “tora” database client package in Feisty Fawn comes with Postgres support, and MySQL if you have the libraries. This How-To shows you how to build Oracle Instantclient 10g support into tora.

This is client only. You will not install the whole Oracle database.

BTW, if you don’t have time to build the whole thing, here is the .deb package I built using this How-To. It’s x386 only, and you’ll need to have instantclient installed before you can use it.

tora_1.3.22-5_i386.deb is an updated .deb package for instantclient 11.1.0.1 and tora 1.3.22.

Continue reading “Tora With Oracle, MySQL”

Tags: , ,


뒷 쪽 »