As a Software Engineer, getting your environment setup can sometimes be a troublesome task and unlike some others, installing certain programs and dependencies can be extremely annoying and tedious. I can say for certain that I had that experience when trying to get PostgreSQL installed as my database. I had a terrible time trying to set get it to work when I was creating an API with Ruby on Rails. But once it was all set it works like a charm. Now you may be asking, “Why should I use PostgreSQL over MySQL or any other databases?“ and for that I will direct you over to this wonderful article titled “PostgreSQL vs MySQL: The Critical Differences”. The first few lines sum it all up but just in case you don’t feel like checking it out:
- Postgres is a feature-rich database that can handle complex queries and massive databases.
- MySQL is simpler database that’s relatively easy to set up and manage, fast, reliable, and well-understood.
- Postgres is an object-relational database (ORDBMS) with features like table inheritance and function overloading, where as MySQL is a pure relational database (RDBMS).
Now, how to set it up:
Head to the download page, click on the Windows logo
Then click on the text “Download the installer”. This will redirect you to chose a version to download.
Select the latest version for your operating system. If you have a 64 bit Windows, select that. If you have a 32 bit, select the latest option from the windows 32 column.
Now that the file is downloaded. Lets get to the installation process!
Once you open the downloaded file, it’ll greet you with the setup wizard.
Leave what’s already preselected and click next:
It’ll ask you where would you like to save your data. You can just click next here as well.
Now here is where you will setup a “superuser” to login into Postgres and gain access to your databases. Make sure to create a memorable password.
Postgres runs on the default port 5433, you can leave this as the default and click next.
This next option has to do with your time. If your system timezone is different than your current timezone, you can make the change here but if not, you can leave it as “Default locale”
After this, you will have the overview of the options you selected thought the setup. Then you click install and let the software install.
Once the install is done, just select next even with stack builder option selected.
You’ll then come across this window and from here you can just hit the ‘x’ on the top right to close this. We won’t be doing anything here.
Hurray! You successfully downloaded Postgres.
Now that you successfully downloaded postgres, open the windows start menu and search “pgAdmin” and you should find something like this:
At the time of reading this, pgAdmin may have a later version out but don’t worry if the version is a different number other than 4. It’ll open up in your web browser and you’ll see it ask you to login with the password you created during the setup.
Now that you’re in, if you dropdown the “PostgreSQL 10" and then Databases, you might not have any databases but we’ll go ahead and set that up in the next blog. But as an example of what you could expect to see:
I have 3 different databases with Postgres. To create a new database, right click on databases, go to create and click “Database”.
Next, under Database, give your database a name then clicked save.
Now you’re ready to role! If you’re interested in using Ruby on Rails to use Postgres with then stay tuned for my upcoming blog post where we learn to do that!