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
postgres
User
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
PostgresSQL
Service
D:\Dev\PostgreSQL\10\bin>pg_ctl.exe register -N PostgreSQL -D D:\Dev\PostgreSQL\10\data
Common Command launches
PostgresSQL
Service
net start PostgreSQL
Stop it
PostgresSQL
Service
net stop PostgreSQL
Delete
PostgresSQL
Service
D:\Dev\PostgreSQL\10\bin>pg_ctl.exe unregister -N PostgreSQL
Windows installation PostgreSQL database failed to initialize database problem