![]() bash: psql: command not (DARWIN-1527) $ /opt/local/lib/postgresql90/bin/psql Now just log into the PostgreSQL server using psql to make sure we're ready to roll: The only thing left to do before starting up the database is edit your ~/.profile or ~/.bash_profile to put the path to the PosgreSQL bin directory into the PATH:Įxport PATH=/opt/local/lib/postgresql90/bin:$PATH The createdb command automatically uses my username as the schema name. $ /opt/local/lib/postgresql90/bin/createdb Shall the new role be a superuser? (y/n) yīecause I made my user a superuser, I can create my own db schema, so log out of the postgres user account and back to my own account first: $ /opt/local/lib/postgresql90/bin/createuser bsnyder LOG: database system is ready to accept connections Execute it as the postgres user ( sudo su - postgres) I tend to cat the log file just to make sure it's running correctly: Now use the pg_start script to start up PostgreSQL. (There is a Mac OS X way of starting PostgreSQL using launchctl but I don't tend to use that because I'm used to the standard pg_ctl command.) ![]() opt/local/lib/postgresql90/bin/pg_ctl -D /opt/local/var/db/postgresql90/defaultdb -l /opt/local/var/log/postgresql90/postgres.log stop opt/local/lib/postgresql90/bin/pg_ctl -D /opt/local/var/db/postgresql90/defaultdb -l /opt/local/var/log/postgresql90/postgres.log start &īelow are the contents of the pg_stop file: Make sure to create these files as the postgres user in the home directory: Below are the contents of the pg_start file. ![]() To prevent having to retype the full command every time I want to start or stop the database, create a start script and a stop script in the postgres user's home directory named pg_start and pg_stop. This is simply because I learned PostgreSQL on Linux and that's all there was. ![]() I prefer to use the pg_ctl command to start and stop PostgreSQL. This should allow you to connect easily using the psql utility. # "local" is for Unix domain socket connections only Now edit the pg_hba.conf file to add the appropriate permissions: NFSHomeDirectory: /opt/local/var/db/postgresql90 View the postgres user account just to make sure it all looks OK: create /Users/postgres UserShell /bin/bash I prefer to change the postgres user's shell to bash: $ sudo -u postgres /opt/local/lib/postgresql90/bin/initdb -D /opt/local/var/db/postgresql90/defaultdb Now you need to initialize the database using the data directory that was created above: $ sudo chown -R postgres:postgres /opt/local/var/log/postgresql90 $ sudo mkdir -p /opt/local/var/log/postgresql90 $ sudo chown -R postgres:postgres /opt/local/var/db/postgresql90 $ sudo mkdir -p /opt/local/var/db/postgresql90/defaultdb Use the MacPorts command port to install PostgreSQL 9.0, then create and own a data directory and a logs directory: I'm hopeful that this will help others as well. So I'm documenting this process for my own sake because I have been through this now twice on two computers recently, having to hunt down all of these commands each time. While installing PostgreSQL 9.0 on Mac OS X again, I had to figure out all these steps yet again.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |