Connecting to Postgres through Powershell/Changing Username
June 4, 2014 11:49 AM   Subscribe

I'm trying to log on to Postgres using Powershell and it's not working. I did this before a little while ago and now I can't remember how I did it and it's driving me crazy.

I know I need to change the powershell username to "postgres" (which, if I remember correctly, then shows up at the beginning of the line instead of "PS") and somehow it uses -U but I can't for the life of me remember how to do it, just that it's fairly simple. The tutorial says "It could also be that you were assigned a PostgreSQL user name that is different from your operating system user name; in that case you need to use the -U switch" which is what I am TRYING to do but there's no explanation of it and Google isn't helping me out very much.

How do I do this and, once I manage that, how do I make Powershell recognize the postgres commands? I've got the folder set up in environment variables but I'm afraid it still won't recognize them. Thanks so much -- I am going bonkers.
posted by Mrs. Pterodactyl to Computers & Internet (8 answers total)
 
I have no idea about powershell but I think probably what you want is something like:
psql -U postgres DATABASE_NAME
...where DATABASE_NAME is the name of the database you created before. But that's on a mac on OS X with a homebrew-installed version of postgres. I'm not sure what the windows situation is.

PS shoot me an IM if you want - happy to talk through this with you! Although probably someone who knows powershell and postgres better than I do will likely wander by.
posted by heresiarch at 1:14 PM on June 4, 2014


the command heresiarch gave should work for connecting to a local postgres database. what error message are you getting when you try to connect?
posted by russm at 5:18 PM on June 4, 2014


Response by poster: Yeah, thanks, at this point I think for some reason Powershell isn't recognizing the Postgres commands at all (I get the standard "not recognized as the name of a cmdlet" that I see all the time). If anyone knows why that might be, I'd be super grateful, thanks!
posted by Mrs. Pterodactyl at 7:33 PM on June 4, 2014


Are you logged into a different account than you usually are? Does Powershell have the authority to what you want it to do? Does this error look similar? If that doesn't help, I'd try posting your error on Stack Overflow. :)
posted by semaphore at 7:50 PM on June 4, 2014


typing:
$ENV:PATH

into Powershell will show you the current places where Powershell will look for your postgres executables.
posted by mmascolino at 8:25 PM on June 4, 2014


Response by poster: Are you logged into a different account than you usually are? Does Powershell have the authority to what you want it to do? Does this error look similar? If that doesn't help, I'd try posting your error on Stack Overflow. :)

I'm logged into Powershell as an admin and logged into Windows as per usual. Yes, that's the error I'm seeing.

typing:
$ENV:PATH

into Powershell will show you the current places where Powershell will look for your postgres executables.


I've got C:\Program Files\PostgreSQL\9.2\data on there -- do I need to be more specific?
posted by Mrs. Pterodactyl at 3:52 AM on June 5, 2014


is the psql executable in the directory c:\program file\postgresql\9.2\data directory?
posted by mmascolino at 6:44 AM on June 5, 2014


Response by poster: In order to avoid chatting in the thread I'll just send a MeFi mail -- thanks for the responses!
posted by Mrs. Pterodactyl at 2:25 PM on June 5, 2014


« Older Help me phrase this effectively.   |   Writers' websites: easy platforms and good... Newer »
This thread is closed to new comments.