前一篇文章(http://www.linuxidc.com/Linux/2013-01/77433.htm)在用yum安装好postgresql之后,就可以通过service来管理它了。这个postgresql-9.1 的位置在/etc/rc.d/init.d/postgresql-9.1可以看到它里面默认使用了一个名为postgres的OS用户名(从这个脚本可以看到很多yum在安装postgresql后的目录位置、环境变量等)。这个postgres用户名就是(http://www.postgresql.org/docs/9.1/static/database-roles.html)这里提到的In order to bootstrap the database system, a freshly initialized system always contains one predefined role. This role is always a "superuser", and by default (unless altered when running initdb) it will have the same name as the operating system user that initialized the database cluster. Customarily, this role will be named postgres. In order to create more roles you first have to connect as this initial role.也就是说,系统会默认创建一个role,而且这个role在不指定(可以通过initdb指定)的情况下,它的name和当前初始化数据库实例的OS用户的name一样的。一般这个name就是postgres。从/etc/rc.d/init.d/postgresql-9.1里面也可以看到,脚本会把很多文件和文件夹的owner设置为postgres。所以当你刚安装好postgres,迫不及待的想通过psql连接数据库的时候都会遇到(http://www.postgresql.org/docs/9.1/static/tutorial-createdb.html)这里提到的错误。因为psql认为你要使用当前的OS用户的name去连接数据库。错误如下:createdb: could not connect to database postgres: FATAL: role "joe" does not exist当然,如果你自己的OS用户的name就是postgres,那你运气就太好了。:D所以你需要su - postgres来切换到postgres用户下去,然后一个简单的:psql就可以顺利的连接到数据库了。然后password 可以修改你的密码。在postgres下面createuser root切换到root下面后,就可以createdb默认创建名为root的数据库。然后psql命令就可以连接到数据库了。利用MySQL客户端批量执行sql语句Oracle联机日志文件丢失或损坏的处理方法相关资讯 PostgreSQL PostgreSQL 9.1 PostgreSQL的使用
- Ubuntu 16.04 下安装 PostgreSQL (08月14日)
- PostgreSQL 发布全系安全更新 (02月12日)
- 使用pg_basebackup搭建PostgreSQL (12/30/2015 09:00:29)
| - Linux下RPM包方式安装PostgreSQL (03月04日)
- PostgreSQL9.5新特性之行级安全性 (01月19日)
- 利用pgpool实现PostgreSQL的高可用 (12/30/2015 08:54:36)
|
本文评论 查看全部评论 (0)