Screwed-up postgresql13 install

Peter West lists at pbw.id.au
Thu Feb 4 03:57:00 UTC 2021


Firstly, the su problem was because I was still in my home directory. When I sudo su - Postgres (note the minus) all is OK.

In my travels I discovered dscl, which I had managed not to encounter over many long year. How very handy it is. I deleted the postgres user with ddcl, and then re-installed postgresql13 and server.

One thing that causes confusion is that the _postgres user in /etc/passwd has a different UID and GID from the dscl user and group. It’s the same on Mojave. I have no idea what these /etc/passwd entries are about, given the underlying differences.

Peter

—
Peter West
peter.b.west at ehealth.id.au
“A prophet is not without honor, except in his hometown and among his relatives and in his own household.”


> On 4 Feb 2021, at 11:45 am, Ryan Schmidt <ryandesign at macports.org> wrote:
> 
> 
> 
> On Feb 3, 2021, at 09:04, Peter West wrote:
> 
>> MacOS Big Sur 11.2 MacBook Air M1
>> 
>> I’m migrating to the M1 from an Intel MacBook Pro running Mojave.
>> 
>> I installed postgresql13 and -server, and copied my defaultdb across from the Pro.
>> 
>> I can’t vouch for the order of these things, because I wasn’t expecting to get into a quagmire.
>> 
>> I tried to give the postgres user a password using passwd as root. That’s not enough. I have to use a command ’security’ with a reference to a Keychain to complete the process. In the wake of all this, I assume that the user postgres is created without a password, and that’s Ok with the default pg_hba.conf.
> 
> As far as I know, anytime MacPorts creates a macOS user account on behalf of a portfile that requests it, it does so without a password, and this is not thought to be a problem. The user accounts do not have a shell set so nobody could log into them.
> 
> 
>> Then I thought that maybe I should build up the databases by dumping databases from the Pro and restoring to the M1. So I uninstalled the postgresql ports and tried to delete /opt/local/var/db/postgresql13. The defaultdb disappeared but root was not allowed to remove a directory Library sitting beside the defaultdb. It had Preferences and Keychains subdirs, and they wouldn’t go.
> 
> I am not certain why. I do not have much experience with macOS 11 yet.
> 
> 
>> I deleted the postgres user through the System Preferences, but that left the entry for _postgres in /etc/passwd.
> 
> The fact that the postgres user was visible in System Preferences indicates a problem. macOS user accounts that MacPorts creates for you are not visible in System Preferences.
> 
> You said you migrated from another Mac. In my experience, the migration assistant will migrate any MacPorts-created user accounts improperly. After migration, the accounts will appear in System Preferences, and their home directories will have been moved into /Users, which may make the ports that use those user accounts not work correctly. Cleaning up the user migration mess that the migration assistant leaves behind is not easy. Whenever I migrate, I choose not to migrate MacPorts-created user accounts and instead have MacPorts recreate them properly.
> 
> I believe the entry for _postgres in /etc/passwd is fine and normal on any macOS system. Apple puts it there, along with creating the _postgres macOS user account. This is unrelated to the postgres macOS user account the MacPorts postgresql-server ports create.
> 
> 
>> Ok, install postgresql13 again. Installation proceeded, but this time did not create the postgres user visible through System Preferences, which I assume was created when I first installed.
> 
> You can check on the command line whether the postgres user created by MacPorts exists:
> 
> id postgres
> 
> If that doesn't show "no such user", you're fine.
> 
> 
>> When I try to access the macports wrapper (via su) to start the database, I get the complaint
>> shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
>> could not identify current directory: Permission denied (3times)
>> The program “postgres” is needed by pg_ctl but was not found in the same directory as pg_ctl
>> (for obvious reasons, me)
>> Check your installation.
>> (you don’t say)
> 
> Not sure, but try cd'ing to a different directory before doing what you did. Maybe you were in a directory that no longer existed. MacPorts has a similar error message that can appear if you are in a port's directory when you run `sudo port sync` because (if you sync with rsync) that deletes all port directories and recreates them.
> 








More information about the macports-users mailing list