database 如何安装/更新到 Postgres 9.4?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27652545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I install/update to Postgres 9.4?
提问by speg
I just installeed Postgres, but it seems to have installed 9.3 and I'd like to start with 9.4
我刚刚安装了 Postgres,但它似乎安装了 9.3,我想从 9.4 开始
I simply did apt-get install postgresqlfrom a new Ubuntu 14.04.1machine.
我只是从一台新的Ubuntu 14.04.1机器上apt-get install postgresql。
http://www.postgresql.org/download/linux/ubuntu/
http://www.postgresql.org/download/linux/ubuntu/
says you can do:
说你可以这样做:
apt-get install postgresql-9.4
but when I try that I get:
但是当我尝试这样做时,我得到:
E: Couldn't find any package by regex 'postgresql-9.4
Okay, so I try the section below where you add the PostgreSQL Apt Repository but that can't find anything either.
好的,所以我尝试在下面添加 PostgreSQL Apt 存储库的部分,但也找不到任何内容。
Is 9.4 not in the package managers yet? Am I doing something horribly wrong?
9.4 还没有在包管理器中吗?我做错了什么吗?
采纳答案by Schwern
postgresql-9.4 is not available in 14.04 "Trusty". It was added in 14.10 "Utopic". It may be back ported in the future.
postgresql-9.4 在14.04 "Trusty" 中不可用。它是在14.10 "Utopic" 中添加的。它可能在未来被移植回来。
The directions on the PostgreSQL Ubuntu Download pageare missing a command. Their wiki guidehas the correct procedure. You must run apt-get update
before trying to install. This will cause the system to read changes to the sources.
在上方向PostgreSQL的Ubuntu的下载页面丢失的命令。 他们的维基指南有正确的程序。您必须apt-get update
在尝试安装之前运行。这将导致系统读取对源的更改。
回答by
You can add it from the instructions in the page
您可以从页面中的说明中添加它
http://www.postgresql.org/download/linux/ubuntu/
http://www.postgresql.org/download/linux/ubuntu/
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update && sudo apt-get install postgresql-9.4
创建文件/etc/apt/sources.list.d/pgdg.list,并为存储库添加一行
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
导入存储库签名密钥,并更新包列表
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update && sudo apt-get install postgresql-9.4
回答by Estev?o Lucas
If you're trying to install on Ubuntu 14.04 "Trusty", you can follow these steps:
如果您尝试在 Ubuntu 14.04“Trusty”上安装,您可以按照以下步骤操作:
To check your version:
要检查您的版本:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
1) Create new apt repo file for postgres
1)为postgres创建新的apt repo文件
$ echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/sources.list.d/pgdg.list
2) Import repository signing key and update packages list
2) 导入存储库签名密钥并更新包列表
$ sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
3) Install Postgres
3) 安装 Postgres
$ sudo apt-get install postgresql-9.4
credit: http://ubuntuhandbook.org/index.php/2014/02/install-postgresql-ubuntu-14-04/
信用:http: //ubuntuhandbook.org/index.php/2014/02/install-postgresql-ubuntu-14-04/
回答by Anvesh
Below are steps to install PostgreSQL 9.4 on Ubuntu 14.04.
以下是在 Ubuntu 14.04 上安装 PostgreSQL 9.4 的步骤。
Reference taken from this Article:
First, check the version of Ubuntu:
首先,检查Ubuntu的版本:
lsb_release -sc
You need to add the latest PostgreSQL repository for the latest version, otherwise It will install PostgreSQL 9.3. This is for trusty version.
您需要为最新版本添加最新的 PostgreSQL 存储库,否则它将安装 PostgreSQL 9.3。这是可信赖的版本。
sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
Update and Install PostgreSQL 9.4:
更新并安装 PostgreSQL 9.4:
sudo apt-get update
sudo apt-get install postgresql-9.4
Default postgres super user and postgres database is created. You need to set a password for the postgres super user.
创建默认的 postgres 超级用户和 postgres 数据库。您需要为 postgres 超级用户设置密码。
ubuntu@:~$ sudo passwd postgres
Enter new UNIX password:****
Retype new UNIX password:****
passwd: password updated successfully
If service is not started, you can start the PostgreSQL service.
如果没有启动服务,可以启动PostgreSQL服务。
sudo service postgresql start
Connect PostgreSQL server using postgres user:
使用 postgres 用户连接 PostgreSQL 服务器:
ubuntu@:~$ su postgres
Password:****
Create a sample database:
创建示例数据库:
createdb database_name
Connect to that database:
连接到该数据库:
psql -d database_name
回答by Ahmad Sharif
Follow these steps to install postgresql. Open the terminal (Ctrl + Alt + t) and then write down the following command line
按照以下步骤安装 postgresql。打开终端(Ctrl + Alt + t),然后写下以下命令行
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6
If postgresql installed successfully then it will return this after writing this command
如果 postgresql 安装成功,那么它会在写这个命令后返回这个
psql --version
psql (PostgreSQL) 9.6.3
回答by Prashant Walke
PostgreSQL is an open source object-relational database system. It is one of leading database server used for production servers. PostgreSQL allows us to execute stored procedures in various programming languages, like PHP, C/C++, Python, Java, Perl, Ruby and its own PL/pgSQL, which is similar to Oracle's PL/SQL.
PostgreSQL 是一个开源的对象关系数据库系统。它是用于生产服务器的领先数据库服务器之一。PostgreSQL 允许我们以各种编程语言执行存储过程,如 PHP、C/C++、Python、Java、Perl、Ruby 及其自己的 PL/pgSQL,类似于 Oracle 的 PL/SQL。
Postgres database is used the persistent store of data
Postgres 数据库用于数据的持久化存储
InstallPostgres
安装Postgres
yum install postgres
(Note : remember the password for the postgres user – you need it later)
(注意:记住 postgres 用户的密码——你以后需要它)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.6
Setting up Postgres
设置 Postgres
Launch pgAdmin.
启动 pgAdmin。
Connect to the local server. Use localhost for the server name, postgres for the username and the password you used when you installed Postgres. You need to be root to perform this command.Note: If you did not set password during installation (sudo apt-get install postgresql), then you can set it as follows:
连接到本地服务器。使用 localhost 作为服务器名称,使用 postgres 作为安装 Postgres 时使用的用户名和密码。执行此命令需要root权限。 注意:如果安装时没有设置密码(sudo apt-get install postgresql),那么可以设置如下:
?
?
sudo -u postgres psql postgres
On the postgres client prompt, use the following command to set the password.
在 postgres 客户端提示符下,使用以下命令设置密码。
alter user postgres with password 'postgres';
Connect to PostgreSQL
连接到 PostgreSQL
After installing PostgreSQL database server, by default,, it creates a user ‘postgres' with role ‘postgres'. It also creates a system account with same name ‘postgres'. So to connect to postgres server, log in to your system as user postgres and connect database.
安装 PostgreSQL 数据库服务器后,默认情况下,它会创建一个角色为“postgres”的用户“postgres”。它还会创建一个同名“postgres”的系统帐户。因此,要连接到 postgres 服务器,请以 postgres 用户身份登录到您的系统并连接数据库。
$ sudo su - postgres
$ psql
Now you are logged in to PostgreSQL database server. To check login info use following command from database command prompt.
现在您已登录到 PostgreSQL 数据库服务器。要检查登录信息,请从数据库命令提示符使用以下命令。
postgres-# \conninfo
To disconnect from PostgreSQL database command prompt just type below command and press enter. It will return you back to Ubuntu command prompt.
要与 PostgreSQL 数据库命令提示符断开连接,只需键入以下命令并按 Enter。它会让你回到 Ubuntu 命令提示符。
postgres-# \q