The following will help you recover your username/pw to a Postgres database so you can convert it to MSSQL format.
You will have a value like this copied:
- "C:\Program Files\PostgreSQL\14\bin\pg_ctl.exe" runservice -N "postgresql-x64-14" -D "Z:\Program Files\PostgreSQL\14\data" -w
- "{BINPATH}\postgres.exe" --single -D "{DATAPATH}" postgres
but with the values replaced. It will look like this:
- "C:\Program Files\PostgreSQL\14\bin\postgres.exe" --single -D "Z:\Program Files\PostgreSQL\14\data" postgres
Run the following commands, one at a time. When you do, you will not receive any feedback from the command prompt:
- CREATE USER dataexport WITH PASSWORD 'dataexport';
- ALTER USER dataexport WITH SUPERUSER;
Press CONTROL+C
- {DATAPATH}\pg_hba.conf
but with the values replaced. It will look like this:
- Z:\Program Files\PostgreSQL\14\data\pg_hba.conf
- host all dataexport 127.0.0.1/32 trust
- host all dataexport ::1/128 trust
- local all dataexport trust
- #The following is an insecure line that can be used in the event that nothing else works
- #Remove the # in front of it to activate it.
- #host all all all trust
1. Log into the server2. Open up Services and find the postgresql-x64-12 service.3. Select "Properties" for the service and note a "Path to Executable" similar to the following:
"C:\Program Files\PostgreSQL\12\bin\pg_ctl.exe" runservice -N "postgresql-x64-12" -D "E:\PostgresDB12" -w
The first path is the install path. The second is the data path.4. Stop the service.5. Navigate to the data path and make a backup of pg_hba.conf6. Edit this file and change "md5" to "trust".7. Restart the Postgres windows service.8. Open command prompt and navigate to the install path.9. Run the following commands:
- psql --username=postgres --no-password
- CREATE USER dataexport WITH PASSWORD 'dataexport';
- ALTER USER dataexport WITH SUPERUSER;
- GRANT ALL PRIVILEGES ON DATABASE prevail to dataexport;
- exit
10. Restore the backup you made of pg_hba.conf11. Restart the Postgres service