使用psycopg2在ubuntu(14.04)中开始使用Postgres

时间:2014-11-01 05:05:22

标签: python postgresql ubuntu psycopg2 postgresql-9.3

我试图开始学习postgres,因为我花了很多时间(浪费了6-7个小时)来确定如何开始。

有很多教程/博客等,但仍然没有得到我应该做的。

具体我还在尝试使用此https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04

eric@eric:~$ sudo apt-get install postgresql postgresql-contrib # succesfully installed version 9.3.5
eric@eric:~$ psql -V
psql (PostgreSQL) 9.3.5
eric@eric:~$ sudo -i -u postgres   # switch to user postgres
postgres@eric:~$

现在我尝试使用createdb命令和其他一些东西创建数据库。但我觉得我陷入困境。 当我尝试更改此用户的密码时,它说

postgres@eric:~$ sudo passwd postgres
[sudo] password for postgres: 
Sorry, try again.
[sudo] password for postgres: 
Sorry, try again.
[sudo] password for postgres: 
Sorry, try again.
sudo: 3 incorrect password attempts

我只想创建一个新用户(带密码)和与之关联的数据库。

有人可以解释设置这些的主要概念和命令 (能够使用这个脚本) http://www.tutorialspoint.com/postgresql/postgresql_python.htm

1 个答案:

答案 0 :(得分:0)

为什么不使用 psql

postgres @ eric:〜$ psql

postgres #create role USERNAME with LOGIN;
postgres#\ password USERNAME - \ password是推荐在postgresql中更改密码的方法

设置密码
确认密码

稍微补助一下 提示:默认情况下,所有公共成员都可以登录数据库,
      但您需要为用户授予对表的操作