прежде чем я начну, я очень новичок в этом, я не имею в виду дезинформировать кого-либо, я просто новичок в переполнении стека.
пытается настроить базу данных postgresql, при запуске команды rails db: setup Postgres установлена. Кто-нибудь знает проблему?
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Couldn't create 'db/mcl-development' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:50:in `rescue in postgresql_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:33:in `postgresql_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:889:in `new_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:933:in `checkout_new_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:912:in `try_to_checkout_new_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:873:in `acquire_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:595:in `checkout'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:439:in `connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1121:in `retrieve_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_handling.rb:238:in `retrieve_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_handling.rb:206:in `connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:126:in `create'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:185:in `block in create_current'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:479:in `block (2 levels) in each_current_configuration'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:476:in `each'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:476:in `block in each_current_configuration'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:475:in `each'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:475:in `each_current_configuration'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:184:in `create_current'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/railties/databases.rake:39:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/command.rb:48:in `invoke'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/commands.rb:18:in `<top (required)>'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
/var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
/home/user1/mycollect/bin/rails:9:in `<top (required)>'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/var/lib/gems/2.5.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/home/user1/mycollect/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/var/lib/gems/2.5.0/gems/pg-0.18.4/lib/pg.rb:45:in `initialize'
/var/lib/gems/2.5.0/gems/pg-0.18.4/lib/pg.rb:45:in `new'
/var/lib/gems/2.5.0/gems/pg-0.18.4/lib/pg.rb:45:in `connect'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:46:in `postgresql_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:889:in `new_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:933:in `checkout_new_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:912:in `try_to_checkout_new_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:873:in `acquire_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:595:in `checkout'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:439:in `connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1121:in `retrieve_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_handling.rb:238:in `retrieve_connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/connection_handling.rb:206:in `connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:126:in `create'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:185:in `block in create_current'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:479:in `block (2 levels) in each_current_configuration'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:476:in `each'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:476:in `block in each_current_configuration'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:475:in `each'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:475:in `each_current_configuration'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/tasks/database_tasks.rb:184:in `create_current'
/var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/railties/databases.rake:39:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/command.rb:48:in `invoke'
/var/lib/gems/2.5.0/gems/railties-6.0.2.1/lib/rails/commands.rb:18:in `<top (required)>'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/lib/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
/var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/lib/gems/2.5.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
/home/user1/mycollect/bin/rails:9:in `<top (required)>'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/var/lib/gems/2.5.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/var/lib/gems/2.5.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/home/user1/mycollect/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:setup => db:schema:load_if_ruby => db:create
(See full trace by running task with --trace)
root@ubuntu:~/mycollect#
Вот так выглядит мой файл базы данных, я следовал учебному пособию:
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/mcl-development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/mcl-test
production:
<<: *default
database: db/mcl-production
Я запустил команду sudo service postgresql start и это в консоли ничего не показывалось, он просто перешел на новую строку, затем я сделал rails s и получил следующую ошибку в localhlost:
PG :: ConnectionBad FATAL: роль "root" не существует Извлеченный источник (вокруг строки # 45):
### Convenience alias for PG::Connection.new.
def self::connect( *args )
return PG::Connection.new( *args )
end
Rails. root: / home / user1 / mycollect Application Trace | Framework Trace | Full Trace pg (0.18.4) lib / pg.rb: 45: в initialize'
pg (0.18.4) lib/pg.rb:45:in
new 'pg (0.18.4) lib / pg.rb: 45: в connect'
activerecord (6.0.2.1) lib/active_record/connection_adapters/postgresql_adapter.rb:46:in
postgresql_connection' activerecord (6.0.2.1) lib / active_record / connection_adapters / abstract / connection_pool.rb: 889: в new_connection'
activerecord (6.0.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:933:in
checkout_new_connection 'activerecord (6.0.2.1) lib / active_record / connection_adapters / abstract / connection_pool.rb: 912: в try_to_checkout_new_connection'
activerecord (6.0.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:873:in
acqu_connection' activerecord (6.0.2.1) lib / active_record / connection_adapters / abstract / connection_pool.rb: 595: in checkout'
activerecord (6.0.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:439:in
connection 'activerecord (6.0.2.1) lib / active_record / connection_adapters / abstract / connection_pool.rb: 1121: в retrieve_connection'
activerecord (6.0.2.1) lib/active_record/connection_handling.rb:238:in
retrieve_connection' activerecord (6.0. 2.1) lib / active_record / connection_handling.rb: 206: в connection'
activerecord (6.0.2.1) lib/active_record/migration.rb:562:in
call 'actionpack (6.0.2.1) lib / action_dispatch / middleware / callbacks.rb: 27: в block in call'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:101:in
run_callbacks' actionpack (6.0.2.1) lib / action_dispatch / middleware / callbacks.rb: 26: in call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in
call 'actionpack (6.0.2.1) lib / action_dispatch / middleware / actionable_exceptions.rb: 17: in call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in
call' веб-консоль (4.0.1) lib / web_console / middleware.rb: 132 : в call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in
блоке вызова в веб-консоли (4.0.1) lib / web_console / middleware.rb: 17: в catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in
вызове actionpack (6.0.2.1) lib / action_dispatch / middleware / show_exceptions.rb: 33 : в call'
railties (6.0.2.1) lib/rails/rack/logger.rb:38:in
call_app 'railties (6.0.2.1) lib / rails / rack / logger.rb: 26: в block in call'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in
блоке с тегом' activesupport (6.0.2.1) lib / active_support / tagged_logging.rb: 28: в tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in
tagged 'railties (6.0.2.1) lib / rails / rack / logger.rb: 26: в call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in
call' actionpack (6.0.2.1) lib / action_dispatch / middleware / remote_ip.rb: 81: в call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in
call 'rack (2.2.2) lib / rack / method_override.rb: 24: в call'
rack (2.2.2) lib/rack/runtime.rb:22:in
call' activesupport (6.0.2.1) lib / active_support / cache / стратегии / local_cache_middleware.rb: 29: в call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in
вызов 'actionpack (6.0.2.1) lib / action_dispatch / middleware / stati c .rb: 126: in call'
rack (2.2.2) lib/rack/sendfile.rb:110:in
call' actionpack (6.0.2.1) lib / action_dispatch / middleware / host_authorization.rb: 83: в call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in
execute_request 'rack-proxy (0.6.5) lib / rack / proxy.rb: 57: in call'
railties (6.0.2.1) lib/rails/engine.rb:526:in
call' puma (4.3.3) lib / puma / configuration.rb: 228: in call'
puma (4.3.3) lib/puma/server.rb:682:in
handle_request 'puma ( 4.3.3) lib / puma / server.rb: 472: в * 10 37 * block in run 'puma (4.3.3) lib / puma / thread_pool.rb: 134: в `block in spawn_thread'