您现在的位置是:网站首页> 编程资料编程资料
ubuntu安装postgresql和使用方法_Ubuntu/Debian_操作系统_
2024-03-20
402人已围观
简介 ubuntu安装postgresql和使用方法_Ubuntu/Debian_操作系统_
安装组件
客户端安装
sudo apt-get install postgresql-client
服务器安装
复制代码
代码如下:sudo apt-get install postgresql postgresql-contrib
获取Installing PostGIS, procedural languages, client interfaces等插件列表
复制代码
代码如下:apt-cache search postgres
Ruby PG gem安装,需要生成Native Extension
首先安装相应package
复制代码
代码如下:sudo apt-get install libpq-dev
找到pg_config所在位置
复制代码
代码如下:sudo find / -name pg_config
安装pg gem
复制代码
代码如下:gem install pg -- --with-pg-config=/usr/bin/pg_config
服务器配置
设置postgres用户,用postgres用户登录并修改密码
复制代码
代码如下:sudo -u postgres psql postgres
为postgres用户设置密码
复制代码
代码如下:\password postgres
创建新数据库
复制代码
代码如下:sudo -u postgres createdb mydb
服务器高级设置
创建用户
复制代码
代码如下:sudo -u postgres createuser --superuser $USER
sudo -u postgres psql
postgres=# \password $USER
管理用户及权限
编辑/etc/postgresql/current/main/postgresql.conf文件用以监听其它网络
复制代码
代码如下:listen_addresses = '*'
创建新用户tesdb及该用户所拥有的数据库testdb
复制代码
代码如下:sudo -u postgres createuser -D -A -P testdb
sudo -u postgres createdb -O testdb testdb
编辑/etc/postgresql/current/main/pg_hba.conf文件,允许testdb用户远程连接testdb数据库
复制代码
代码如下:host testdb testdb 0.0.0.0/0 md5
重新加载配置
复制代码
代码如下:sudo /etc/init.d/postgresql reload
重启数据库
复制代码
代码如下:sudo /etc/init.d/postgresql restart
相关内容
- Linux中 如何查看Ubuntu内存信息? 查看内存信息的命令_Ubuntu/Debian_操作系统_
- ubuntu怎么开启root帐号 ubuntu 开启root帐号方法图解 _Ubuntu/Debian_操作系统_
- ubuntu系统如何切换root用户身份 ubuntu切换root用户帐号方法 _Ubuntu/Debian_操作系统_
- Ubuntu14.04 远程连接Win7 报错:无法连接到RDP服务器_Ubuntu/Debian_操作系统_
- ahjesus安装mongodb企业版for ubuntu的步骤_Ubuntu/Debian_操作系统_
- CF感恩节你想对他(她)说什么活动网址及活动奖励一览_网络游戏_游戏攻略_
- 魔兽世界6.0瓦拉沙的蛋如何触发 宠物小多头蛇获取攻略_网络游戏_游戏攻略_
- 魔兽世界6.0火车王成就获取详细攻略_网络游戏_游戏攻略_
- 剑灵南天国各副本物品掉落更新一览 22日副本掉落_网络游戏_游戏攻略_
- 剑网3苍雪龙城太原之战逐虎驱狼秘境攻略_网络游戏_游戏攻略_
