CentOS 6.2 上 PostgreSQL 9.1 的使用,在用yum安装好postgresql之后,就可以通过service来管理它了。这个postgresql-9.1 的位置
前一篇文章()在用yum安装好postgresql之后,就可以通过service来管理它了。这个postgresql-9.1 的位置在
/etc/rc.d/init.d/postgresql-9.1
可以看到它里面默认使用了一个名为postgres的OS用户名(从这个脚本可以看到很多yum在安装postgresql后的目录位置、环境变量等)。这个postgres用户名就是()这里提到的
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连接数据库的时候都会遇到()这里提到的错误。因为psql认为你要使用当前的OS用户的name去连接数据库。错误如下:
createdb: could not connect to database postgres: FATAL: role "joe" does not exist
当然,如果你自己的OS用户的name就是postgres,那你运气就太好了。:D
所以你需要
su - postgres
在线证件照系统是一套完善的冲印行业解决方案,致力于解决用户线上拍摄证件照,拍摄最美最标准证件照的使命。证件照免费版功能:后台统计:当天制作、当天新增、支持规格、近7日统计规格列表:筛选查看、编辑用户列表:筛选查看常见问题:筛选查看、新增、编辑、删除小程序设置:应用设置、流量主设置小程序跳转:筛选查看、新增、编辑、删除关注公众号:引导设置系统要求:系统:Linux系统(centos x64)运行环境
1
来切换到postgres用户下去,然后一个简单的:
psql
就可以顺利的连接到数据库了。
然后\password 可以修改你的密码。
在postgres下面
createuser root
切换到root下面后,就可以
createdb
默认创建名为root的数据库。然后psql命令就可以连接到数据库了。

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号