Install PostgreSQL on Mac OS X

Last Updated at : November 29, 2017 By - Usama Muneer | 2321

    Introduction

    If you’re new to PostgreSQL and facing issues configuring on your mac machine. Well we’re here for the rescue.

    PostgreSQL is an open-source relational database management system (DBMS) for creating & maintaining the set of data & information for your application.

    Installing PostgreSQL using Homebrew

    Open up a new terminal window and paste in the following command to install postgres on you mac.

    brew update
    brew install postgresql

    Wait for the process to complete. HomeBrew will take care of all the dependencies required for Postgres on your machine.

    Try running the following command to check if its installed correctly.

    postgres -V

    It should return the postgres version installed on your machine.

    postgres sql screenshot

    you can also run postgres --help to have a look at all the available options with postgres command.

    Configuring postgreSQL

    At this point, you have successfully installed postgres on your mac. Next step is to setup the configuration.

     

    Creating users

    Enter the postgres shell and create new root user to handle all the permissions.

    By default, postgres will create a user by your system name and assign all the roles necessary. Additionally you can create a new user if required by entering into psql command shell.

    psql
    CREATE ROLE root LOGIN PASSWORD 'root' [CREATEDB]

    This will create a new user for your Postgres with user name and password of root and can create new databases.

    Creating Databases

    Since we’ve successfully created a new user, creating databases is almost as easy.

    createdb mydatabasename -U root;

    Well yes, thats right, that’s it for the database.

    Setting up the right GUI Tool

    If you’re kinda familiar with sequelPro, then you might like PSequel. Although its still in its beta development but fulfils all the basic needs.

    Moreover, if you have to deal with big data and manage your tables along with the every little trigger and stats. PgAdmin is there for you.

    Give them both a try and leave us your comments below. My personal favourite is PSequel for its clean UI though.

    You can also follow us on Twitter.

     

     

    blog user
    Usama Muneer

    A web enthusiastic, self-motivated & detail-oriented professional Full-Stack Web Developer from Karachi, Pakistan with experience in developing applications using JavaScript, WordPress & Laravel specifically. Loves to write on different web technologies with an equally useful skill to make some sense out of it.

    Related Posts

    Telescope gives knowledge into the solicitations coming into your application, exemptions, log sections, database questions, lined employments, mail, notices, reserve activities, planned errands, variable dumps and that's just the beginning.

    Laravel Live Islamabad, ended on 24th Nov'18 & we got a lot to learn from the top-notch of speakers & influencers. Thanks to the sponsors for pulling off such a great event in the capital of Pakistan.

    Inspired from Laravel's router, lets build our very own PHP's router for managing our endpoints well for our next PHP project.

    Another #LaraconUS in the books & It was the 6th instalment of #LaraconUS happened at Chicago with full swing & we got a lot to learn this time with exceptional line of speakers and never-ending community support by fellow Artisans