Páginas

domingo, 6 de noviembre de 2011

PostgreSQL


Instalar PostgreSQL, phppgadmin en Gentoo.

Fuente: http://www.gentoo.org/doc/es/postgres-howto.xml
http://www.codigolibre.org


En mi sistema gentoo-linux actual tengo instalado el servidor web apache, el gestor de base de datos mysql y php. Instalar postgresql y phppgadmin, crear la base de datos sacademico y ejecutar un script para importar la estructura de las tablas y los datos, así lo hice:

Añadir al fichero /etc/make.conf la use postgres
# emerge -av postgresql-server

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   N   ] dev-db/postgresql-server-9.0.5  USE="nls pam xml -doc -perl -pg_legacytimestamp -python (-selinux) -tcl -uuid" LINGUAS="en es -af -cs -de -fa -fr -hr -hu -it -ko -nb -pl -pt_BR -ro -ru -sk -sl -sv -tr -zh_CN -zh_TW" 0 kB

Total: 1 package (1 install), Size of downloads: 14,015 kB

Would you like to merge these packages? [Yes/No]

Editar el fichero /etc/conf.d/postgresql-9.0, para el idioma castellano PG_INITDB_OPTS="--locale=es_ES.UTF-8":
# vim /etc/conf.d/postgresql-9.0

# Location of configuration files
 PGDATA="/etc/postgresql-9.0/"

 # Where the data directory is located/to be created
 DATA_DIR="/var/lib/postgresql/9.0/data"

 # Additional options to pass to initdb.
 # See 'man initdb' for available options.
 PG_INITDB_OPTS="--locale=en_US.UTF-8"

Crear el cluster de base de datos y almacenar los ficheros relacionados con el servidor en PGDATA y DATA_DIR.
# emerge --config dev-db/postgresql-server:9.0

Cambiando 'trust' a 'password' para las conexiones a localhost
vim /etc/postgresql-9.0/pg_hba.conf
# "local" is for Unix domain socket connections only
 local   all             all                        trust
 # IPv4 local connections:
 host    all             all       127.0.0.1/32     trust
 # IPv6 local connections:
host    all             all        ::1/128          trust

Agregar usuario al grupo postgres:
# gpasswd -a carlos postgres

Iniciar el servidor
# /etc/init.d/postgresql-9.0 start
 * Caching service dependencies ...           [ ok ]
 * Starting PostgreSQL ...                    [ ok ]

Abrir una conexión al servidor y cambiar la contraseña:
# psql -U postgres
psql (9.0.3)
Type "help" for help.

postgres=# \password
Enter new password:
Enter it again:
postgres=# \q

Crear un usuario y su password:
# su - postgres
 psql -U postgres
postgres@hypatia ~ $ createuser sacademico -Ws

Clave: kikla
postgres@hypatia ~ $ createdb sacademico


Enlace al script:

enlace_descarga_dhypatia.sql

*Insertar el script bdhypatia.sql:
postgres@hypatia:~$psql sacademico < bdhypatia.sql -U postgres

# /etc/init.d/postgresql-9.0 reload
postgresql-9.0 | * Reloading PostgreSQL configuration ...  [ ok ]

Iniciar postgresql con el sistema:
# rc-update add postgresql-9.0 default
 * service postgresql-9.0 added to runlevel default

Instalar phppgadmin

# emerge -av phppgadmin
Recompila php con soporte postgres e instala phppgadmin.

Para poder logearnos via navegador (/http://localhost/phppgadmin y no recibir un mensaje login failed será necesario editar el fichero /var/www/localhost/htdocs/phppgadmin/conf/config.inc.php y agregar 'localhost':
# vim /var/www/localhost/htdocs/phppgadmin/conf/config.inc.php

// use 'localhost' for TCP/IP connection on this computer
   $conf['servers'][0]['host'] = 'localhost';

# /etc/init.d/postgresql-9.0 reload



Linux es genial!.

No hay comentarios:

Publicar un comentario