Windows installation PostgreSQL database failed to initialize database problem

Source: Internet
Author: User
Tags postgresql postgresql version

Background

Because of the needs of the project, the database PostgreSQL is used, so the database is installed on Windows PostgreSQL . However, after installation, the local database cannot be accessed, this time to view the /data directory, without any files. And during the installation, pop-up prompt box

Problem running Post-Install step. Installation may isn't complete correctly the database cluster initialisation failed.
Initialization of DB cluster failed during installation

System environment
    • Operating system: Windows ten Pro
    • PostgreSQL version: 10.4-1
    • Account: Non-Super Admin account
Reason

In Windows 10, if you are using an Microsoft account, you are not a super administrator, you cannot create a user at this time, and you cannot create the corresponding DB user when you install through the installation package. And in the account cannot see postgres This user, so can guess, when the permissions are insufficient, unable to create the corresponding user's account, and no corresponding account, unable to initialize the db.

Solution View Users
net  user
Create Postgres User
net user postgres postgres /add
Establishing the data directory at the database root directory
D:\Dev\PostgreSQL\10>md data
Remove Super Administrator permissions to the data directory
D:\Dev\PostgreSQL\10>cacls data /e /t /r administrator处理目录:D:\Dev\PostgreSQL\10\data
Assign permissions to the data directory to the postgresUser
D:\Dev\PostgreSQL\10>cacls data /e /t /r postgres:C处理目录:D:\Dev\PostgreSQL\10\data
Initializing the database
D:\Dev\PostgreSQL\10\bin>initdb.exe -D ../data -E UTF-8 --locale=chs -U postgres -W

After initialization, you need to enter a new user password to log in to the database.

Start the database
D:\Dev\PostgreSQL\10\bin>pg_ctl.exe -D D:\Dev\PostgreSQL\10\data -l logfile start

Registered PostgresSQLService
D:\Dev\PostgreSQL\10\bin>pg_ctl.exe register -N PostgreSQL -D D:\Dev\PostgreSQL\10\data
Common Command launches PostgresSQLService
net start PostgreSQL
Stop it PostgresSQLService
net stop PostgreSQL
Delete PostgresSQLService
D:\Dev\PostgreSQL\10\bin>pg_ctl.exe unregister -N PostgreSQL

Windows installation PostgreSQL database failed to initialize database problem

Related Article

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.