如何在PostgreSQL 8.4中安装pgcrypto?

我使用的是Ubuntu Server 10.10,我使用apt-get install postgresql安装了Postgresql 8.4.我想使用内置的sha1()函数,但似乎我必须首先安装pgcrypto.但我不知道如何安装它.

如果我尝试使用apt-get install pgcrypto安装它并且我没有在我的系统中找到以pgcrypto开头的任何文件(我尝试查找/ -name“pgcrypto *”),则没有pgcrypto.

如何安装pgcrypto以便在数据库查询中使用摘要(‘word-to-hash’,’sha1′)函数

更新:我正在努力在另一台Ubuntu机器上安装pgcrypto.使用sudo apt-get install postgresql-contrib-8.4安装软件包之后如何将其安装到我当前的Postgresql数据库中?

对于较新版本的PG,请查看Dustin Kirkland的答案

这是Postgres的外部模块.你应该通过apt安装postgresql-contrib-8.4(或你的pg版本)包:

apt-get install postgresql-contrib-8.4

然后在/usr/share / postgresql文件夹中的某处找到sql install文件,你需要在数据库上运行pgcryto.sql.

psql -d <database> -f /usr/share/postgresql/8.4/contrib/pgcrypto.sql

要么,

$cd /usr/share/postgresql/8.4/contrib
$psql -d <database>
    psql (8.4.8)
    Type "help" for help.

    database=# \i pgcrypto.sql

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...