Use of PostgreSQL 6.2 on CentOS 9.1

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.