前端之家收集整理的这篇文章主要介绍了
如何在PostgreSQL 8.4中安装pgcrypto?,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用的是Ubuntu Server 10.10,我使用apt-get install
postgresql安装了Postgre
sql 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