您现在的位置是:网站首页> 编程资料编程资料
ubuntu安装postgresql和使用方法_Ubuntu/Debian_操作系统_
2023-03-27
635人已围观
简介 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_操作系统_
- 如何清理 Ubuntu 14.04 的最近打开文件历史列表 保护个人隐私_Ubuntu/Debian_操作系统_
- 在ubuntu14.04下使用网页版qq的方法图文介绍_Ubuntu/Debian_操作系统_
- 在Ubuntu Trusty 14.04 (LTS) (64-bit)安装Docker的步骤_Ubuntu/Debian_操作系统_
- ubuntu下右键菜单添加新建word、excel文档等快捷方式_Ubuntu/Debian_操作系统_
- Canonical 集成Unity8到ubuntu的细节计划_Ubuntu/Debian_操作系统_
