In the previous article (), after installing postgresql with yum, you can manage it through service. This postgresql-9.1 is located
/Etc/rc. d/init. d/postgresql-9.1
You can see that it uses an OS username named postgres by default (from this script, you can see many yum directories and environment variables after postgresql is installed ). This postgres user name is (http://www.postgresql.org/docs/9.1/static/database-roles.html) mentioned here
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.
That is to say, the system will create a role by default, and this role is not specified (can be specified through initdb, its name is the same as the OS User name of the currently initialized database instance. Generally, this name is ipvs. You can also see from the/etc/rc. d/init. d/postgresql-9.1 that the script sets the owner of many files and folders to ipvs.
So when you have just installed postgres, you can't wait to connect to the database through psql will encounter the (http://www.postgresql.org/docs/9.1/static/tutorial-createdb.html) mentioned here error. Because psql considers that you need to use the name of the current OS user to connect to the database. The error is as follows:
Createdb: cocould not connect to database postgres: FATAL: role "joe" does not exist
Of course, if the name of your OS user is ipvs, you're lucky. : D
So you need
Su-postgres
To switch to the ipvs user, and then a simple:
Psql
You can connect to the database smoothly.
Then \ password can be used to change your password.
Under ipvs
Createuser root
Switch to the root directory.
Createdb
By default, a database named root is created. Then the psql command can connect to the database.