我刚刚通过以下方式重新安装了 postgres brew install postgres
我跑了initdb /usr/local/var/postgres -E utf8但得到了这个:
The files belonging to this database system will be owned by user "atal421".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an …Run Code Online (Sandbox Code Playgroud) 有谁知道如何在 Mac OS 10.6 上安装libpq-dev?这是我要安装的其他东西的先决条件。
似乎没有它的 macport,那么我如何在 Mac 上安装它?
在过去的某个时候,我安装了 posgresql 并且无法摆脱它:
$ ps -A|egrep postg 232 ??
287 ?? 0:00.02 postgres: logger process
328 ?? 0:00.09 postgres: writer process
335 ?? 0:00.06 postgres: wal writer process
336 ?? 0:00.03 postgres: autovacuum launcher process
342 ?? 0:00.01 postgres: stats collector process
Run Code Online (Sandbox Code Playgroud)
我想在每次启动时阻止它启动,因为fs_usage它显示我的磁盘一直被占用。
我已经尝试添加POSTGRES=-NO-in /etc/hostconfig,但过程不断产生。
我也尝试过在另一篇文章中找到的东西,但没有运气:
$: locate postg|egrep plist
/Library/LaunchDaemons/com.edb.launchd.postgresql-8.4.plist
/Library/PostgreSQL/8.3/uninstall-postgresql.app/Contents/Info.plist
/Library/PostgreSQL/8.4/uninstall-postgresql.app/Contents/Info.plist
/Library/StartupItems/postgresql-8.3/StartupParameters.plist
$: sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-8.4.plist
(restart)
Run Code Online (Sandbox Code Playgroud)
但仍然显示 postgresql 进程:(
删除 Macports 后,我有一些奇怪的行为。当我尝试通过 CLI 运行 PostgreSQL 时,我得到:
pawel:~ pawel$ psql
dyld: Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/bin/psql
Reason: image not found
Trace/BPT trap
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我已经通过 Homebrew 安装了 Postgresql 并运行brew list确认它在那里。我如何让 psql 再次工作?
此外,由于错误,尝试安装pg gem失败file not found: /opt/local/lib/libssl.1.0.0.dylib。我需要让 Postgres 不在 /opt/local/ 目录中查找此文件。
我在 Ubuntu 上工作。以下是我的命令之一。
$ psql -U kuser -d postgres
Run Code Online (Sandbox Code Playgroud)
然后这将连接到数据库。但是当我尝试时从 postgres 终端
postgres=> CREATE DATABASE kdb;
ERROR: permission denied to create database
Run Code Online (Sandbox Code Playgroud)
当我在 Ubuntu 中尝试类似的命令时,它给出了以下内容
$ sudo -u kuser createdb kdb
sudo: unknown user: kuser
sudo: unable to initialize policy plugin
Run Code Online (Sandbox Code Playgroud)
我如何创建这个数据库?。我有 sudo 权限,而 kuser 不是我。
我想知道如何在 PostgreSQL 中执行 .sql 文件。我正在使用 CentOs 6.4。
我已经创建了一个数据库,只需要运行给我的脚本来创建表。
提前谢谢你。
我最近通过Homebrew在我的 Mac 上安装了 PostgreSQL 。(我可能已经安装了它;它没有运行。)
brew install postgres
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Run Code Online (Sandbox Code Playgroud)
现在我试图用它开始launchctl:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Run Code Online (Sandbox Code Playgroud)
...但我收到一个错误:
/usr/local/Cellar/postgresql/9.4.0/homebrew.mxcl.postgresql.plist:不允许操作
这个错误是什么意思?我究竟做错了什么?我该如何解决这个问题?
所以我在 MacOSX Lion 上成功安装了 PostgreSQL 9.1。与人们说的不同,我不必更改 PATH 并且系统上没有安装其他版本的 PostgreSQL($ psql --version
显示psql (PostgreSQL) 9.1.4)。
但是,当我尝试使用pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start它运行服务器时,它不起作用。首先,它说不存在目录/usr/local/var/postgres/。很好,创建了一个。然后它说权限是错误的 - 好吧,改变它们。然后它要求postgresql.conf文件在这个目录中。
现在,我在 中找到了示例配置/usr/local/Cellar/postgresql/9.1.4/share/postgresql,但我不确定这是否应该是这样。我在网上看到的所有手册都没有提到从样本中创建配置文件。自制软件不应该开箱即用,以便我立即启动服务器吗?
当我尝试使用 LibreOffice Base 3.5 连接到本地计算机上的 PostgreSQL 服务器时遇到错误(这也适用于 LibreOffice 4):

以下语法 ( localhost:5432=<database name>; 数据库名称worktime) 不起作用:

当我尝试在下一页测试连接时,出现以下错误:
数据库 URL 错误 'sdbc:postgresql:localhost:5432=localhost':
无效的连接选项“localhost:5432”
数据源 URL 的正确语法是什么?
psql命令行客户端的语法是
psql [option...] [dbname [username]]
Run Code Online (Sandbox Code Playgroud)
我将命令传递ALTER DATABASE x RENAME to y给这个命令:
echo `ALTER DATABASE x RENAME to y` | psql
Run Code Online (Sandbox Code Playgroud)
目前我收到错误
psql: FATAL: database "myuser" does not exist
Run Code Online (Sandbox Code Playgroud)
看起来该psql命令试图打开与当前用户名同名的数据库。
如何在psql不选择任何数据库的情况下启动命令?
编辑:
解决方法当然只是为用户创建一个空数据库。
使用数据库x作为参数不起作用,因为这会阻止重命名。