我在公司环境中(运行Debian Linux)并没有自己安装它.我使用Navicat或phpPgAdmin访问数据库(如果有帮助的话).我也没有shell访问运行数据库的服务器.
我是postgres新手.
我安装了postgres.app for mac.我正在玩psql命令,我不小心删掉了postgres数据库.我不知道里面是什么.
我正在制作一个教程:http://www.rosslaird.com/blog/building-a-project-with-mezzanine/
我被困在了 sudo -u postgres psql postgres
错误信息: psql: FATAL: role "postgres" does not exist
$ ps psql
/Applications/Postgres.app/Contents/MacOS/bin/psql
Run Code Online (Sandbox Code Playgroud)
这是打印出来的 psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------+------------+----------+---------+-------+---------------------------
user | user | UTF8 | en_US | en_US |
template0 | user | UTF8 | en_US | en_US | =c/user +
| | | | | user =CTc/user
template1 | user | UTF8 | …Run Code Online (Sandbox Code Playgroud) 重新启动MacBook Pro后,我无法启动数据库服务器:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
我检查了日志,然后一遍又一遍地出现以下行:
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.0.4.
Run Code Online (Sandbox Code Playgroud)
9.0.4是预装在mac上的版本,9.2 [.4]是我通过Homebrew安装的版本.如前所述,这曾经在重启之前工作,所以它实际上不是一个编译问题.我也重新运行initdb /usr/local/var/postgres -E utf8,文件仍然存在.
不幸的是,我对Postgres很新,所以任何帮助都会非常感激.
我在我的Mac OS Lion上安装了PostgreSQL,正在开发一个rails应用程序.我使用RVM将所有内容与其他Rails应用程序分开.
出于某种原因,当我第一次尝试迁移数据库时,rake无法找到postgres用户.我收到了错误
FATAL: role "postgres" does not exist
Run Code Online (Sandbox Code Playgroud)
我有pgAdmin所以我可以清楚地看到数据库中有一个postgres用户 - 实际上是管理员帐户 - 所以我不知道还能做什么.
我在某处读过有关PostgreSQL问题的人,因为它安装了哪条路径,但是如果它找不到db那么我认为我不会那么远.
我正在尝试第一次设置Postgres,我需要创建一个具有读取和创建数据库权限的用户.但是,当我在终端中使用"createuser username"时,我收到以下消息:
createuser:无法连接到数据库postgres:致命:角色"tom"不存在
Tom是我现在登录的Ubuntu用户帐户.我正在尝试创建"postgres"的用户名,然后执行"psql -U psql template1",这样我就可以创建一个数据库并为我的Rails应用程序分配一个所有者.
有帮助吗?
我最近最新版本的ubuntu,我还不习惯.我有几个问题连接postgresql与pgadmin3.
我尝试按照几个教程创建一个localhost服务器,我可以在pgadmin3中使用它.我没有真正达到标准,我认为通过安装,卸载,安装,卸载,尝试我找到的答案,我做得更糟......此时我不确定我的postgres是否干净.我可能有两个postgres安装,再次,我不确定.我试图卸载它,但我有一个错误,基本上说postgres不在sudo.
问题是我现在在控制台中运行psql时出现此错误:
$psql
psql: FATAL: role "user" does not exist
Run Code Online (Sandbox Code Playgroud)
我找不到pg_hba.conf,在这一点上,我太害怕通过尝试跟随任何其他帖子使事情变得更糟.
我怎么能做这个工作?
开发一个仅限API的Rails应用程序来使用API中的数据,过滤掉许多字段,然后广播我们想要公开的字段.
我的应用程序正常返回数据,但我意识到在源API级别上,我们更改了我们正在公开的数据字段之一的数据类型.为了适应,我提交了我的工作,检查了一个新分支,运行迁移以更改数据字段的数据类型,决定我对它的工作方式不满意,回滚迁移,提交和签出主分支.该应用正常返回数据.但是,现在当我使用取景器的方法,如在Rails的控制台测试我的模型的记录.first,.last等等,我得到下面的错误.他们以前工作得很好.
我环顾四周,并没有看到任何关于这个特定错误的线程(他们似乎都在寻找显示页面的个别记录) - 虽然这个,这个线程(通过扩展)看起来最接近.检查我正在使用的数据库上的用户显示错误中的用户ID("501")不存在.
我做了什么,我需要做什么才能再次调用finder方法?我是否需要在我的数据库中的错误中创建引用的用户?(为什么它不是我一直用来连接到我的数据库的默认用户?错误中的用户ID来自哪里?它甚至重要吗?)
ps - 如果它是相关的,我曾经rake db:rollback根据这个线程回滚我的迁移.
提前致谢.
Rails控制台
.2.1 :001 > KoboApi.first
ActiveRecord::NoDatabaseError: local user with ID 501 does not exist
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `rescue in connect'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis_adapter.rb:51:in `initialize'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis/create_connection.rb:37:in `new'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-postgis-adapter-3.1.4/lib/active_record/connection_adapters/postgis/create_connection.rb:37:in `postgis_connection'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
from /Users/toby/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
from /Users/toby/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block …Run Code Online (Sandbox Code Playgroud) 当我尝试启动postgresql时出现错误:
postgres
Run Code Online (Sandbox Code Playgroud)
postgres不知道在哪里可以找到服务器配置文件.
您必须指定--config-file或-D invocation选项或设置PGDATA环境变量.
那么我尝试设置我的配置文件:
postgres -D /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
postgres无法访问服务器配置文件"/usr/local/var/postgres/postgresql.conf":权限被拒绝
嗯好的 接下来,我尝试执行与管理员相同的操作:
sudo postgres -D /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
不允许"root"执行PostgreSQL服务器.
必须在非特权用户ID下启动服务器,以防止可能的系统安全性受损.有关如何正确启动服务器的详细信息,请参阅文档.
我搜索了该错误消息,但无法找到解决方案.
任何人都可以对此提供一些见解吗?
我创建了一个vagrant实例,每次我尝试psql在终端中执行此操作时我都会收到此错误.错误是状态:
psql:致命:角色"vagrant"不存在
我以为流浪汉会照顾这个?这是我的流浪文件:
Vagrant.require_plugin "vagrant-omnibus"
Vagrant.require_plugin "vagrant-berkshelf"
Vagrant.configure(2) do |config|
# Box config
config.vm.box = 'precise64'
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
# Plugin config
config.omnibus.chef_version = :latest
config.berkshelf.enabled = true
# Network config
config.vm.network :forwarded_port, guest: 3000, host: 3000
# Virtual config
config.vm.provider(:virtualbox) do |vb|
vb.customize [
"modifyvm", :id,
"--memory", "1024",
"--cpus", "4"
]
end
# Provisioner config
config.vm.provision :chef_solo do |chef|
chef.add_recipe 'apt'
chef.add_recipe 'postgresql::client'
chef.add_recipe 'postgresql::server'
chef.add_recipe 'build-essential'
chef.add_recipe 'rvm::system'
chef.add_recipe 'git'
chef.json = {
:postgresql => { …Run Code Online (Sandbox Code Playgroud) 我正在Windows中设置我的PostgreSQL 9.1.
我对PostgreSQL无能为力:无法创建b,无法创建用户; 所有操作都返回错误消息
致命:角色根不存在
root是我的帐户名,是我在安装时创建的Postgresql
但我可以使用以下连接:
username : postgres
Run Code Online (Sandbox Code Playgroud)
如何使用角色连接到postgres root?
有使用su命令Linux平台中提到的解决方案在这里,但无法找出针对windows7解决方案
提前致谢
postgresql ×9
macos ×2
activerecord ×1
database ×1
homebrew ×1
pgadmin ×1
privileges ×1
psql ×1
rake ×1
roles ×1
sudo ×1
terminal ×1
ubuntu ×1
vagrant ×1
windows-7 ×1