我不知道Postgresql如何在Mac上创建用户 [英] I dont know how Postgresql created user on my mac

查看:532
本文介绍了我不知道Postgresql如何在Mac上创建用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两天前,我开始学习postgresql。我在线上关注的大多数教程都是过时的,否则代码将无法在Mac上正常工作。我遵循了很多教程,这些教程做了很多完全不同的事情。
今天打开系统时。我注意到Postgresql在我的Mac上创建了一个用户。我不知道这是什么,或者我使用了错误的CLI代码。

Two days ago, i started learning postgresql. Most tutorials I followed online were either old or the codes wont just work on my mac. I followed a lot of tutorials that did a lot of totally different things. When i switched on my system today. I noticed Postgresql created a user on my mac. I don't know what this is or maybe i used the wrong CLI code.

当我尝试查看用户时,我看到了

When I tried viewing the user, I saw this

我应该删除

推荐答案

postgres 用户帐户



为Postgres创建一个用户帐户,通常称为 postgres ,这是Postgres安装的常规步骤。安装程序可能会提示您输入密码以分配给该新用户帐户。

postgres user account

Creating a user account specifically for Postgres, commonly named postgres, is a normal part of a Postgres installation. Your installer app likely prompted you for a password to assign to this new user account.

原因之一是安全性:数据库的数据文件和安全配置文件存储在 postgres 用户拥有的文件夹中。因此,如果您的主要用户帐户被劫持,入侵者将无法访问数据库(通常是存储中最有价值的东西)。入侵者必须越跳越多,以破坏Postgres。同样,单独的所有权可以防止其他应用无意间踩过Postgres文件。

One reason for this is security: The database’s data files and security configuration files are stored in folders owned by the postgres user. So if your main user account is hijacked, the intruder does not yet have access to the database (often the most valuable thing in storage). The intruder must jump through more hoops to compromise Postgres. Also, the separate ownership prevents other apps from inadvertently stomping on the Postgres files.

您会发现,Postgres比其他产品(如MySQL)更面向企业。这意味着锁定安全性。另一个示例:默认情况下,Postgres配置为通过网络接受连接。要启用来自其他计算机的连接,必须更改配置。初学者不方便,但更安全。就像汽车方向盘上的横杆和车门上的锁舌一样,更高的安全性总是意味着需要采取更多的步骤,并且会感到烦恼。

You will find Postgres is much more enterprise-oriented than other products such as MySQL. This means locking-down for security. Another example: Postgres by default is configured to not accept connections over the network. To enable connections from other computers, you must change the configuration. Inconvenient for the beginner, but more secure. Like a bar on your car steering wheel and deadbolts on your doors, more security always means more steps to take and more annoyance.

安装 postgres 用户帐户是使Postgres成为重量级安装的原因之一。我建议那些学习Postgres的人将虚拟机用于Postgres。像这样的东西:

Installing the postgres user account is one of the things that makes Postgres a rather heavyweight installation. I suggest to those learning Postgres to use a virtual machine for Postgres. Something like:

  • Parallels or Fusion or VirtualBox on your own computer
  • Cloud server such as FreeBSD on DigitalOcean.com.

要删除Postgres,只需丢弃虚拟机。

To remove Postgres, simply discard the vm.

Mac用户的另一个选项是 Postgres.app ,由构建第一个Postgres-as-a服务实现之一的人创建(在 Heroku )。我没有使用过 Postgres.app ,但是我知道它包装了Postgres,因此它没有安装 postgres 用户帐户。另外,Postgres在启动并退出应用程序时会启动和停止,而不是一直在后台运行。

Another option for a Mac user is Postgres.app, created by the person who built one of the first Postgres-as-a-Service implementations (on Heroku). I have not used Postgres.app, but I understand it wraps Postgres, so it does not install the postgres user account. Also, Postgres starts and stops when launch and quit the app, rather than running in the background all the time.

请注意:您可能已经在使用常规安装的Mac上与Postgres.app发生冲突。我建议您首先仔细从Mac上删除常规Postgres ,然后再安装Postgres.app。卸载涉及在不同位置查找和删除各种文件和文件夹。

Be aware: you may have conflicts with Postgres.app on a Mac where you already have a conventional installation. I suggest you first carefully remove the conventional Postgres from your Mac before installing Postgres.app. Uninstalling involves finding and deleting various files and folders in various places.

避免本地安装的另一种选择是增加将Postgres作为服务运行的选择。由于供应商会代您维护Postgres的安装,因此有时将其称为托管Postgres。您只是使用 Postgres创建数据库,但是您没有完全控制 Postgres这样的服务。

Another option to avoid local installation is the increasing choices for running Postgres as a service. This is sometimes referred to as "managed Postgres" because the vendor maintains the installation of Postgres on your behalf. You simply use Postgres to create your database, but you do not fully control Postgres in such a service.

一些示例:

  • Heroku
  • Azure
  • Amazon Web Services (AWS)
  • ElephantSQL

我个人经常将Postgres安装在Mac使用EnterpriseDB.com的安装程序。该公司出售Postgres的增值版本,但请为普通的Postgres提供安装程序,以为社区提供服务。

Personally, I often install Postgres on a Mac using the installer by EnterpriseDB.com. That company sells added-value versions of Postgres, but kindly provides an installer for plain-vanilla Postgres, as a service to the community.

我也使用了相同的安装程序从EnterpriseDB.com安装到在运行macOS作为主机OS的MacBook Pro上,在VM上的VM上作为来宾OS运行macOS的Parallels VM。您可以轻松地将VM配置为在网络上共享主机Mac的IP地址,也可以为VM提供自己的网络地址,这对于进行演示/开发/测试工作可能会很方便。

I have also used that same installer from EnterpriseDB.com to install onto a Parallels VM running macOS as the guest OS within the VM on a MacBook Pro running macOS as the host OS. You can easily configure the VM to share the host Mac’s IP address on the network, or you can give the VM its own network address which might be handy for demo/dev/test work.

第三,我已经在DigitalOcean.com的FreeBSD上安装了Postgres。

Thirdly, I have installed Postgres on FreeBSD on DigitalOcean.com.

这三个选项对我来说都非常有效。哪种情况更好取决于情况。例如,如果我希望同事在没有我自己的MacBook的情况下能够24x7访问数据库,那么DigitalOcean.com的方法很好。

All three of these options have worked quite well for me. Which is preferable depends on the scenario. For example, the DigitalOcean.com approach is good if I want colleagues to be able to reach the database 24x7 without my own MacBook being available.

此讨论用于开发工作。对于关键任务部署,我强烈建议使用具有纠错内存的重型服务器设备。和冗余存储,例如 RAID ZFS池。 Postgres非常可靠,但当然取决于可靠的硬件。

This discussion is for development work. For mission-critical deployment, I strongly recommend using heavy-duty server equipment with error-correcting memory and redundant storage such as RAID or ZFS pool. Postgres is extremely reliable but depends, of course, on reliable hardware.

您的标签上写着Postgres 9.1。该版本现在已经很旧了。我建议使用最新版本。顺便说一句,postgres的版本编号系统已更改。现在,第一个数字是大概每年发布的数字,可能需要您转储和重新加载数据以进行升级,而第二个数字是兼容的更新。

Your tag says Postgres 9.1. That version is quite old now. I suggest using the latest version. By the way, the version numbering system has changed for postgres. The first number is now the roughly-annual release number likely requiring you to dump and reload data to upgrade, and the second number is compatible updates.

这篇关于我不知道Postgresql如何在Mac上创建用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆