frankcollins3 / PHPokedex

react concepts
0 stars 0 forks source link

5432 taken, but by a deleted psql server? 👻 [11:34pm] #25

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

Screen Shot 2023-05-09 at 11 31 17 AM

I had Postgres.APP (the elephant icon on menubar) I was having problems with my models not persisting through prisma and express, even upon a successful db connection. prisma.model.findMany() was returning {test: null}

First proposed approach: re-download POSTGRES, configure CLI, and keep the server running on PORT 5432 as expected

[11:50am]

frankcollins3 commented 1 year ago

Screen Shot 2023-05-09 at 11 53 45 AM

this terminal command making use of superuser do shows the activity on the specified PORT.: sudo lsof -i :5432

sudo pkill -u postgres this terminal command fails because there is no psql user (deleted it from groups)

[11:54am]

frankcollins3 commented 1 year ago

pointer / symbolic link related PSQL clearing:

sudo rm /usr/local/bin/clusterdb sudo rm /usr/local/bin/createdb sudo rm /usr/local/bin/createuser sudo rm /usr/local/bin/dropdb sudo rm /usr/local/bin/dropuser sudo rm /usr/local/bin/initdb sudo rm /usr/local/bin/pg_config sudo rm /usr/local/bin/pg_dump sudo rm /usr/local/bin/pg_dumpall sudo rm /usr/local/bin/pg_restore sudo rm /usr/local/bin/postgres sudo rm /usr/local/bin/psql

the requirement to be unusually thorough with handling these many files made me see that one could bundle these steps and create a C console program to:

execute all of these steps with minimal user input required. (sudo has enough to do with these files. they can grab lemonade)

frankcollins3 commented 1 year ago

https://bgasparotto.com/find-and-kill-processes-on-linux-and-mac-by-port-number [12:34pm]

frankcollins3 commented 1 year ago

Screen Shot 2023-05-09 at 12 34 45 PM

PID coming back from the dead

1) lsof -i :${PORT} 2) new port

[12:38pm]

frankcollins3 commented 1 year ago

C program:

Screen Shot 2023-05-09 at 1 04 11 PM

frankcollins3 commented 1 year ago

proposed approach:

Screen Shot 2023-05-09 at 3 44 12 PM

localhost:postgres. I believe PG as a VS code dependency is occupying the PORT. restarting the computer and checking back.

[3:45pm]

frankcollins3 commented 1 year ago

https://dba.stackexchange.com/questions/52306/howto-disable-postgres-listening-on-tcp****

Screen Shot 2023-05-09 at 3 47 28 PM

specifying search by TCP which is included in the

TCP localhost:postgresql (LISTEN)

again, what led me to think of the C program that interacts with the terminal through sudo comments, I completely wiped postgres from machine as far as the statements detailed way above go.

postgres [other arguments] -c listen_addresses=''

[3:47pm]

frankcollins3 commented 1 year ago

deleted 220+ folders: postgres/bytea postgres/date

tried getting screenshot while deleting

[3:54pm]

frankcollins3 commented 1 year ago

https://stackoverflow.com/questions/42416527/postgres-app-port-in-use

[3:57pm]

frankcollins3 commented 1 year ago

wow time to add this command to https://github.com/frankcollins3/pseudo_sudo

Screen Shot 2023-05-09 at 4 01 04 PM

Screen Shot 2023-05-09 at 4 00 58 PM

this solves everything instantly.

[4:02pm]

frankcollins3 commented 1 year ago

the hidden 👻 terminal 👻 command 👻

Screen Shot 2023-05-09 at 4 05 43 PM

brew services stop postgresql

if problem: 20 minutes ---> wouldn't have thought of using a C program to tackle the problem

cant count the amount of different ways: psql is not a command postgres no user found etc...

[4:09pm]

frankcollins3 commented 1 year ago

Screen Shot 2023-05-09 at 4 10 37 PM

bookmark. Spent a few hours on psql, few hours sidetracked coding in C just to see if I could interact with terminal. I saved a db.md file so that the libraries, PORT#, destination settings are stored somewhere.

also learned a lesson on my PORT being :5433 (probably because of :5432 being used by some version of postgres that wasn't deleted through all of the $statements)

[4:12pm]

frankcollins3 commented 1 year ago

Screen Shot 2023-05-09 at 4 16 09 PM

[4:16pm]

frankcollins3 commented 1 year ago

I don't think this needs another issue but:

Screen Shot 2023-05-09 at 4 25 52 PM

problem: postgres tables come with a \dt relation of user

first proposed approach: create table users ( {...} ) ;

[4:32pm]