I cannot access PostgreSQL through the command line in Windows. Although I am able to create and update the databases, access them through PGAdminIII, and push to Heroku, I am unable to access them directly through my command line using the psql command.
When I try to create a database by using the command
$ createdb mydb
as explained in the PG documentation, I get the message
createdb: command not found
The documentation suggests that in this case, "PostgreSQL was not installed properly. Try calling the command with an absolute path instead." Sure enough, I am able to create a database by entering the direct path to the file:
$ c:/postgreSQL/9.1/bin/createdb mydb
Does this mean that the path can be reconfigured to connect correctly? Or do I need to reinstall? I've reinstalled several times, and have not been able to set the correct path. I currently have both the /bin and /lib paths addedto my system and user(:Umezo) paths, but still no access from the command line.
User variables for umezo variable name: Path variable value: C:\PostgreSQL\9.1\bin; C:\PostgreSQL\9.1\lib System variables variable name: Path variable value: C:\PostgreSQL\9.1\bin; C:\PostgreSQL\9.1\lib
Any information or feedback regarding how I can fix my installment would be appreciated.
My info is as below:
I mostly followed these sources here and here. I installed a 32 bit version of 9.1 because some sources suggested issues with 64 bit.
PG download version: Installer Version 9.1 Win x86-32 Operating System: Windows 7 (64 bit)
pg_hba.conf
#TYPE DATABASE USER CIER-ADDRESS METHOD # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5
postgresql.conf
# - Connection Settings - listen_addresses = '*' port = 5432 max_connections = 100
pg_ident.conf
# *Everything is commented out*
Login Role Umezo #from properties window in PGAdminIII
Properties/Role name: Umezo Properties/Can login: "check" Role privileges: all categories "check"
You can find postgresql. conf and look at param data_directory . If it is commented then database directory is the same as this config file directory. It will be depending on the distribution, they all do it slightly differently.
For example, if the database server machine is a remote machine, you will need to set the PGHOST environment variable to the name of the database server machine. The environment variable PGPORT may also have to be set.
Server [localhost]: I enter localhost; Database [postgres]: I enter postgres; Port [5432]: I enter 5432; Username [postgres]: I enter postgres; Password for user postgres: I enter the password which is "a". and which works.
I encountered this issue too. I'm using Git Bash, hence the Unix-style $ prompt on Windows.
$ rails db Couldn't find database client: psql, psql.exe. Check your $PATH and try again.
Here's what I did:
In Windows 7, navigate to:
Control Panel All Control Panel Items System Advanced System Settings Environment Variables from the System Variables box select "PATH" Edit...
Then append this string to the existing PATH Variable Value:
;C:\Program Files\PostgreSQL\9.2\bin
and click "OK" three times to exit the menus.
Now, close the console and restart it.
Navigate back to the directory of your Rails app. In my case, this is accomplished with:
$ cd rails_projects/sample_app
Then, try again:
$ rails db
sources:
How do I put PostgreSQL /bin directory on my path in Windows?
http://railscasts.com/episodes/342-migrating-to-postgresql?view=asciicast
open my Computer ==> right click inside my computer and select properties ==> Click on Advanced System Settings ==> Environment Variables ==> from the System Variables box select "PATH" ==> Edit... ==>
then add this at the end of whatever you find their
;C:\PostgreSQL\9.2\bin; C:\PostgreSQL\9.2\lib
after that continue to click OK
open cmd/command prompt.... open psql in command prompt with this
psql -U username database
eg. i have a database name FRIENDS and a user MEE.. it will be
psql -U MEE FRIENDS
you will be then prompted to give the password of the user in question. Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With