ubuntu16.4安装postgresql
来源:互联网 发布:淘宝千牛怎么开直通车 编辑:程序博客网 时间:2024/06/06 06:56
最近在学习postgresql,于是打算在电脑上把数据库装上。看了网上的教程,突出一个字简单。然而,我却遇到许多莫名其妙的问题。
具体步骤就不说了,
安装
- 创建文件 /etc/apt/sources.list.d/pgdg.list,根据系统版本添加下面这行
#14.04deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main#16.04deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main#17.04deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main
这样能获得最新版本的postgresql,如果要安装其他版本
sudo apt install postgresql-xxx
2.安装完之后,直接输入psql,会显示以下错误
psql: could not connect to server: No such file or directory Is the server running locally and acceptingconnections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
服务没有开启,输入命令:
#xx替换为版本号sudo systemctl start postgresql@xx-main.service
安装有多版本的话
#切换到postgres用户sudo su postgres#列出所有分支pg_lsclusters
问题
接下来就是我遇到的坑了
1. ubuntu dpkg: error processing package postgresql-common (–configure)….
具体错误一大堆:
dpkg: error processing package postgresql-common (--configure): subprocess installed post-installation script returned error exit status 127dpkg: dependency problems prevent configuration of postgresql-9.3: postgresql-9.3 depends on postgresql-common (>= 142~); however: Package postgresql-common is not configured yet.dpkg: error processing package postgresql-9.3 (--configure): dependency problems - leaving unconfigureddpkg: dependency problems prevent configuration of postgresql: postgresql depends on postgresql-9.3; however: Package postgresql-9.3 is not configured yet.dpkg: error processing package postgresql (--configure): dependency problems - leaving unconfiguredNo apport report written because the error message indicates its a followup error from a previous failure. No apport report written because the error message indicates its a followup error from a previous failure. Processing triggers for ureadahead (0.100.0-16) ...Errors were encountered while processing: postgresql-common postgresql-9.3 postgresqlE: Sub-process /usr/bin/dpkg returned an error code (1)
然而主要错误就是,postgresql-common安装失败。如果你已经尝试了网上所有解决方案都没有解决,可以尝试下面这种:
备份/var/lib/dpkg/status文件
sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.bak
然后打开文件该文件,查找postgresql-common
Package: postgresql-common#关键就在这里Status: install ok half-configuredPriority: optionalSection: database
注意到报错是 not configured yet,于是我尝试将状态改为 install ok installed (参照了其他正常安装的包)。安装成功,关于这些状态区别可以去查看其他资料。
2. 关于psql: could not connect to server:
No such file or directory Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?
这个错误比较隐蔽,我是通过查看日志解决的。一般服务开启,端口没有被占用,数据都能正常连接。但是,我始终没法连接数据库,查看日志发现错误是无法转换localhost。我突然想起,自己曾经改过hosts文件。打开/etc/hosts,添加:
127.0.0.1 localhost
阅读全文
0 0
- ubuntu16.4安装postgresql
- 安装PostgreSQL与PostGIS (Ubuntu16.04LTS)
- Ubuntu16.4 安装 redis
- Ubuntu16.4安装Anaconda
- postgresql 9.4.4 安装
- ubuntu16.04 安装tensorflow1.4
- ubuntu16.4安装谷歌
- Ubuntu16.04安装PostgreSQL并使用pgadmin3管理数据库_图文详解
- PostgreSql 9.4.4 安装部署
- 安装Postgresql
- postgresql 安装
- Postgresql安装
- 安装Postgresql
- postgresql安装
- postgresql 安装
- postgresql 安装
- PostgreSQL安装
- postgresql 安装
- 关于预编译头 protocol buffer 命名空间的问题
- css3的一些学习笔记
- 【java基础】接口的意义及用法!
- DAS/SAN/NAS之区别
- 最终实现混合app仿淘宝app自动识别淘口令 第二篇 从后台转到前台时自动识别剪贴板内容
- ubuntu16.4安装postgresql
- 比较总结线性表的几种主要存储结果
- /verbose:lib让VisualStudio打印更详细的编译错误信息
- Java静态绑定与动态绑定 隐藏 多态
- error LNK2005: "void __cdecl operator delete(void *)"错误解决方案
- Boosteroid——人人可用的个人云计算机
- 局部和全局变量浅析
- Python Scrapy运行爬虫时出现ModuleNotFoundError(win32api)
- 优先队列 使用 (补一发)