- Установка и подключение PostgreSQL на Mac Os
- Установка PostgreSQL на Mac Os
- Не обязательно
- Подключение к PostgreSQL на Mac OS
- Как подключиться к PostgreSQL на Mac OS
- Подключение в сторонней программе к БД
- DataGrip
- Исправление ошибок
- Читайте также
- How to Start PostgreSQL Server on Mac OS X via Homebrew
- Install PostgreSQL via Homebrew
- Using a LaunchAgent and plist to Launch PostgreSQL on Startup
- Manually Starting PostgreSQL
- Start/Stop PostgreSQL Without Homebrew
- Startup Troubleshooting: Did You Run initdb ?
- PostgreSQL Setup : Mac Edition
- Reduce your efforts on PostgreSQL installation and issues in Mac OS with these 4 steps
- Step 1 : Getting Homebrew
- Step 2: Installing PostgreSQL
- Step 3: Initialize Database
- Step 4.1: Connect to database via command line
- 17 Practical psql Commands That You Don’t Want To Miss
- Summary: in this tutorial, we give you a list of common psql commands that helps you query data from PostgreSQL…
- Step 4.2: Connect to database via Popular GUIs
- Recommended GUIs
- 1. Postico
- 2. pgAdmin
- 3. DataGrip
- How to setup PostgreSQL on MacOS
- PostgreSQL Installation on MacOS
- How to create a physical PostgreSQL Database
- How to start/stop a PostgreSQL Database
- How to create the actual PostgreSQL Database
- Keep reading about В Node
- How to setup MongoDB on MacOS
- How to setup PostgreSQL on Windows
- The Road to React
Установка и подключение PostgreSQL на Mac Os
Устанавливаем PostgreSQL на Mac OS.
Установка PostgreSQL на Mac Os
Добавляем в автозапуск при старте системы Mac OS.
Также можно запустить вручную:
Не обязательно
Если автозагрузка не сработает. Можно провести такие манипуляции:
Директория автозагрузки находится здесь:
Добавляем в автозагрузку
Подключение к PostgreSQL на Mac OS
Подключение на Mac OS немного отличается от Linux. Проверим пользователей:
Для подключения указываем Owner из таблицы выше:
Как создать БД и пользователя, следовать инструкции:
https://ploshadka.net/postgresql/
Если коротко, то для локалки достаточно ввести в консоль:
Как подключиться к PostgreSQL на Mac OS
На localhost достаточно создать базу данных и подключиться к ней указав только её имя:
Остальное подхватиться по умолчанию.
Подключение в сторонней программе к БД
DataGrip
На примере программы DataGrip:
Исправление ошибок
Статья по исправлению некоторых ошибок с правами доступа.
Читайте также
Кстати, на сайте нет рекламы. У сайта нет цели самоокупаться, но если вам пригодилась информация можете задонатить мне на чашечку кофе в макдаке. Лайкнуть страницу или просто поблагодарить. Карма вам зачтется.
Источник
How to Start PostgreSQL Server on Mac OS X via Homebrew
Install PostgreSQL via Homebrew
Likely most OS X users know of Homebrew , but Homebrew is a package manager for OS X that allows you to easily install and run a massive library of applications and utilities with ease.
We won’t go through the entire (albeit short) installation process of Homebrew, but if you wish to install Homebrew and use it for PostgreSQL management, check out the installation command on the official documentation. If you aren’t sure if Homebrew is installed, try the which brew command from the terminal to verify.
Once Homebrew is installed, you can install PostgreSQL by issuing the following commands in your terminal:
The first two commands are used to update Homebrew and report any potential issues (if necessary). Then, of course, brew install postgres is the one-line command for installing PostgreSQL.
You should see a good deal of useful information in the output during installation, much of which should be copied down for use in the next sections.
Using a LaunchAgent and plist to Launch PostgreSQL on Startup
In most cases, you’ll likely wish to have PostgreSQL launch when you start up your system, so you’ll need to tell your computer this is your desire.
First, you’ll need to create a directory for your LaunchAgents to reside (if the directory doesn’t exist already). LaunchAgents in OS X are simple scripts used by launchd that cause the system to run programs or code during startup.
Create your user -specific LaunchAgents directory with this command, if necessary:
Now you’ll need to create a symbolic link from the script that actually allows Postgres to run to the LaunchAgents directory. A symbolic link is similar to creating a new copy of a file for use in another directory, but since the link is вЂsymbolic’, the link is just a forwarding address: any request made to that symbolic link location is actually “forwarded along” or redirected to where the real file actually resides.
Link to the plist (property list) file that was generated by Homebrew and place that new symbolic link in LaunchAgents with this command:
Note: Double-check that the command is correct: It should’ve been part of the installation output mentioned above when Homebrew installed Postgres initially.
Finally, we load the new symbolic link’ed LaunchAgent file using the launchctl load command, which is specifically what informs the computer to run this script and start Postgres when the computer launches. Again, the exact command to enter for your own installation will be an output during Homebrew’s Postgres installation, but it should look something like this:
Manually Starting PostgreSQL
To manually startup Postgres without rebooting, again you should be able to use the command that was output during the installation, like so:
This will attempt to launch Postgres in daemon mode, which means it will be running as a background process without taking over your terminal.
Start/Stop PostgreSQL Without Homebrew
In the event that you don’t have (or don’t wish to use) Homebrew for Postgres, yet you have Postgres installed already, you can also manually start it with pg_ctl , which is the launch utility provided by Postgres itself.
This will start Postgres (assuming default directories):
And this will stop Postgres:
Startup Troubleshooting: Did You Run initdb ?
In some cases, if you have trouble running Postgres, be sure you’ve executed the initdb command one time, which causes Postgres to initialize the database cluster for a new installation and allows you to connect with the default postgres user.
Источник
PostgreSQL Setup : Mac Edition
Reduce your efforts on PostgreSQL installation and issues in Mac OS with these 4 steps
PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and technical standards compliance. It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users.
If you already have Homebrew installed, you can skip to Installing PostgreSQL. Otherwise, let’s keep going.
Step 1 : Getting Homebrew
To install PostgreSQL on the command line we will be using a package manager called Homebrew. In MacOSX 10.7 or higher, the Ruby interpreter comes pre-installed. Let’s start by copying and pasting the following command into our command line:
Step 2: Installing PostgreSQL
The first thing we’re going to do is install Postgres. There are two main ways to get Postgres onto your machine:
- Using a graphical installer like BigSQL or Postgres.app (Requires macOS 10.12 for latest)
- Using a package manager to install via the command line.
You can pick whichever option is right for you. For this tutorial, let’s see how to install on the command line.
How to check if PostgreSQL is installed in you mac?
Remove previous versions of PostgreSQL
Delete all Files of Postgres
Install Postgres with Homebrew
Start PostgreSQL server
To have launchd start postgresql now and restart at login:
Or, if you don’t want/need a background service you can just run:
Step 3: Initialize Database
If terminal shows an error like below:
Remove old database file
rm -r /usr/local/var/postgres
Run the initdb command again
Step 4.1: Connect to database via command line
Postgres works pretty hard to make itself usable right out of the box without you having to do anything. By default, it automatically creates the user postgres . Let’s see what other users it has created. Let’s start by using the psql utility, which is a utility installed with Postgres that lets you carry out administrative functions without needing to know their actual SQL commands.
Start by entering the following on the command line:
(You may need to use sudo psql postgres for this command to work, depending on how your system is configured).
17 Practical psql Commands That You Don’t Want To Miss
Summary: in this tutorial, we give you a list of common psql commands that helps you query data from PostgreSQL…
Step 4.2: Connect to database via Popular GUIs
There are many clients for PostgreSQL on the Mac. You can find many of them in the Community Guide to PostgreSQL GUI Tools in the PostgreSQL wiki. Some of them are quite powerful; some are still a bit rough. Here’s a list of all the Mac Apps I found (in alphabetic order):
Recommended GUIs
1. Postico
Postico is a modern Postgres client for OSX, built by the same developer who built Postgres.app (mentioned above). It is free, but you can buy a license to unlock additional power features. This is the GUI that I use to manage Postgres because it is built specifically for Mac and has a beautiful, very easy to use (but powerful) UI. It also includes an SQL editor for complex queries.
2. pgAdmin
pgAdmin is the oldest of the Postgres GUIs, its first version being released just a few months after Postgre’s first release in 1996. Having been rewritten several times, it can run on Linux, MacOSX, and Windows, and features powerful database management tools including a syntax-highlighted SQL editor. Designed to run on both client machines and on deployed servers, pgAdmin is capable of handling advanced cases that Postico cannot. It’s dashboard is one of it’s kind and is an absolute essential tool when using Postgres in a distributed microservice architecture.
3. DataGrip
DataGrip is my favorite when it comes to IDEs. It is a modern IDE developed by JetBrains that offers efficient schema navigation, an intelligent query console, and version control integration. DataGrip also resolves references in your SQL code and helps you refactor them.
Источник
How to setup PostgreSQL on MacOS
This is a tutorial for setting up PostgreSQL on MacOS. You might be wondering why there’s a need for another setup guide for Postgres in the first place, since there are a few across the web. I found many tutorials and guides on how to set it up, but found most of them to be unclear and outdated, based on old PostgreSQL versions. The checklist is not comprehensive, though, as it is used for several tutorials on my website, I keep it updated with the recent versions of PostgreSQL. If you spot any flaws in this guide, a comment below would be very helpful to keep it up to date for other developers.
If you want to run PostgreSQL on Windows instead, you will find guidance over here: How to setup PostgreSQL on Windows.
PostgreSQL Installation on MacOS
I recommend Homebrew for installing and managing applications on MacOS. It is installed using the following command in the MacOS terminal:
The terminal runs through a series of installation operations, and will probably create folders in your local machine to accommodate Homebrews storage requirements. You can find more detailed instructions here. After it’s installed, update the Homebrew dependencies and install PostgreSQL on the command line:
Next, check your PostgreSQL version:
The command line results will show the version you have installed on your local machine. I recommed using the latest version of libraries and software whenever possible to avoid compatibility issues with client-side applications.
How to create a physical PostgreSQL Database
Now you can initialize the physical space on your hard-disk to allocate databases. To do this, create a default postgres database on the command line in case it didn’t happen automatically:
You will see the error message: «initdb: directory «/usr/local/var/postgres» exists but is not empty» if the database was already created when you installed PostgreSQL. It means the folder where you are attempting to create a physical place for the database already has one. Either way, next you can move on to the next step.
When you connect to this physical database later, you will see an actual database which is called «postgres» as well. The postgres database is meant to be the default database for any third-party tools that you are using in combination with PostgreSQL. These tools attempt to make the default connection to this default database, so you shouldn’t delete it.
How to start/stop a PostgreSQL Database
Let’s see next how you can interact with the actual database. Manually start and stop your Postgres database server with the following commands:
The terminal will confirm these operations with «server started» and «server stopped» feedback. You could also implement a script to start the server each time you boot up the machine, but I like to have control over when to start and stop my database server to avoid complications.
How to create the actual PostgreSQL Database
Next, let’s go through the steps of setting up a database that can be used for one of your applications. Make sure the Postgre server is started first, then type these commands in the command line to create and remove a database:
You can also connect to databases to execute SQL statements. Either use the psql command, or specify a database such as the default postgres database to connect:
The command leads you to the psql shell, which you can exit by typing CTRL + d. In the psql shell, you can create and drop databases as well:
To list all your databases, you can type \list . Your will see any new databases listed, as well as two default databases that come with postgreSQL called template0 and template1 . The templates should remain in your database list even if you aren’t using them, as they may be useful later.
- \list — List all of your actual databases.
- \c mydatabasename — Connect to another database.
- \d — List the relations of your currently connected database.
- \d mytablename — Shows information for a specific table.
Keep reading about В Node
How to setup MongoDB on MacOS
This is a tutorial for setting up MongoDB on MacOS. You might be wondering why there’s a need for another setup guide for MongoDB in the first place, since there are a few across the web. I found many…
How to setup PostgreSQL on Windows
This is a tutorial for setting up PostgreSQL 11 on Windows. You might be wondering why there’s a need for another setup guide for Postgres in the first place, since there are a few across the web. I…
The Road to React
Learn React by building real world applications. No setup configuration. No tooling. Plain React in 200+ pages of learning material. Learn React like 50.000+ readers.
Источник