{"id":21,"date":"2013-02-28T14:53:00","date_gmt":"2013-02-28T14:53:00","guid":{"rendered":""},"modified":"2021-08-31T10:12:45","modified_gmt":"2021-08-31T09:12:45","slug":"creating-and-running-postgresql-on-mac","status":"publish","type":"post","link":"https:\/\/www.srivittal.com\/wp\/?p=21","title":{"rendered":"Creating and running Postgresql on mac"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">I am using macports for the installation<\/p>\n<p>Run<\/p>\n<p><span style=\"color: white;\"><span style=\"background-color: black;\">sudo port install postgresql92<\/span><\/span><\/p>\n<p>and then<\/p>\n<p><span style=\"color: white;\"><span style=\"background-color: black;\">sudo port install postgresql92-server<\/span><\/span><\/p>\n<p>Once the server has been installed, run the following<\/p>\n<p>To create a database instance, after install do<\/p>\n<p><span style=\"color: white;\"><span style=\"background-color: black;\">&nbsp;sudo mkdir -p \/opt\/local\/var\/db\/postgresql92\/defaultdb<br \/>&nbsp;sudo chown postgres:postgres \/opt\/local\/var\/db\/postgresql92\/defaultdb<br \/>&nbsp;sudo su postgres -c &#8216;\/opt\/local\/lib\/postgresql92\/bin\/initdb -D \/opt\/local\/var\/db\/postgresql92\/defaultdb&#8217;<\/span><\/span><\/p>\n<p>The output you will see<\/p>\n<p><span style=\"color: white;\"><span style=\"background-color: black;\">The files belonging to this database system will be owned by user &#8220;postgres&#8221;.<br \/>This user must also own the server process.<\/p>\n<p>The database cluster will be initialized with locale &#8220;en_GB.utf-8&#8221;.<br \/>The default database encoding has accordingly been set to &#8220;UTF8&#8221;.<br \/>The default text search configuration will be set to &#8220;english&#8221;.<\/p>\n<p>fixing permissions on existing directory \/opt\/local\/var\/db\/postgresql92\/defaultdb &#8230; ok<br \/>creating subdirectories &#8230; ok<br \/>selecting default max_connections &#8230; 20<br \/>selecting default shared_buffers &#8230; 1600kB<br \/>creating configuration files &#8230; ok<br \/>creating template1 database in \/opt\/local\/var\/db\/postgresql92\/defaultdb\/base\/1 &#8230; ok<br \/>initializing pg_authid &#8230; ok<br \/>initializing dependencies &#8230; ok<br \/>creating system views &#8230; ok<br \/>loading system objects&#8217; descriptions &#8230; ok<br \/>creating collations &#8230; ok<br \/>creating conversions &#8230; ok<br \/>creating dictionaries &#8230; ok<br \/>setting privileges on built-in objects &#8230; ok<br \/>creating information schema &#8230; ok<br \/>loading PL\/pgSQL server-side language &#8230; ok<br \/>vacuuming database template1 &#8230; ok<br \/>copying template1 to template0 &#8230; ok<br \/>copying template1 to postgres &#8230; ok<\/p>\n<p>WARNING: enabling &#8220;trust&#8221; authentication for local connections<br \/>You can change this by editing pg_hba.conf or using the option -A, or<br \/>&#8211;auth-local and &#8211;auth-host, the next time you run initdb.<\/p>\n<p>Success. You can now start the database server using:<\/p>\n<p>&nbsp;&nbsp;&nbsp; \/opt\/local\/lib\/postgresql92\/bin\/postgres -D \/opt\/local\/var\/db\/postgresql92\/defaultdb<br \/>or<br \/>&nbsp;&nbsp;&nbsp; \/opt\/local\/lib\/postgresql92\/bin\/pg_ctl -D \/opt\/local\/var\/db\/postgresql92\/defaultdb -l logfile start<\/span><\/span><\/p>\n<p>Switch to the postgres id using<\/p>\n<p><span style=\"color: white;\"><span style=\"background-color: black;\">sudo su &#8211; postgres<\/span><\/span><\/p>\n<p>Then run the following command<\/p>\n<p><span style=\"color: white;\"><span style=\"background-color: black;\">\/opt\/local\/lib\/postgresql92\/bin\/postgres -D \/opt\/local\/var\/db\/postgresql92\/defaultdb<\/span><\/span><\/p>\n<p>The output will be<\/p>\n<p><span style=\"color: white;\"><span style=\"background-color: black;\">LOG:&nbsp; database system was shut down at 2013-02-28 14:43:36 GMT<br \/>LOG:&nbsp; database system is ready to accept connections<br \/>LOG:&nbsp; autovacuum launcher started <\/span><\/span><\/p>\n<p>Once you run the above command as suggested, the server will be available for use<\/p>\n<p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I am using macports for the installation Run sudo port install postgresql92 and then sudo port install postgresql92-server Once the server has been installed, run the following To create a database instance, after install do &nbsp;sudo mkdir -p \/opt\/local\/var\/db\/postgresql92\/defaultdb&nbsp;sudo chown postgres:postgres \/opt\/local\/var\/db\/postgresql92\/defaultdb&nbsp;sudo su postgres -c &#8216;\/opt\/local\/lib\/postgresql92\/bin\/initdb -D \/opt\/local\/var\/db\/postgresql92\/defaultdb&#8217; The output you will see The files &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,26,27,28],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-installation","category-mac-osx","category-macports","category-postgres-sql","entry entry-center"],"_links":{"self":[{"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":1,"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":112,"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions\/112"}],"wp:attachment":[{"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.srivittal.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}