postgresql – Main postgres database is not tracked by pg_ctl. Can I fix this?

I created a directory in postgres user’s home dir called mydb: /var/lib/postgresql/mydb

I did this using initdb -D mydb.

Now, I want to start postgres and use mydb as the location where all this db’s data is stored; so I run:

pg_ctl -D /var/lib/postgresql/mydb start

It starts successfully, but if I try:

psql (12.6 (Ubuntu 12.6-0ubuntu0.20.04.1))
Type "help" for help.

postgres=# show data_directory;
       data_directory        
-----------------------------
 /var/lib/postgresql/12/main
(1 row)

i.e. it’s using the “main” or default data directory, completely ignoring the -D argument.

So now it occurs to me that I might be connecting to a different db… even though running pg_ctl status before pg_ctl start gives me:

pg_ctl: no server running

However, this has to be the case because… with “no server running”, I am able to psql and query the main database.

So then, how do I get the main database “tracked” by pg_ctl? Also, how do I use psql to connect to the right database?

Thank you

Edit: was able to connect to the postgres started with pg_ctl using:

psql -h /var/run/postgresql

(even though I don’t see any changes to that directory’s contents before / after I pg_ctl start i.e. it remains: 12-main.pg_stat_tmp 12-main.pid).