gpt4 book ai didi

mysql - Rails Mysql ActiveRecord::ConnectionNotEstablished

转载 作者:行者123 更新时间:2023-11-29 20:30:14 25 4
gpt4 key购买 nike

我创建了一个新的rails应用程序,当我启动服务器并尝试连接它时,它给了这个服务器

错误

activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
activerecord (4.0.0) lib/active_record/connection_handling.rb:79:in `retrieve_connection'
activerecord (4.0.0) lib/active_record/connection_handling.rb:53:in `connection'
activerecord (4.0.0) lib/active_record/query_cache.rb:51:in `restore_query_cache_settings'
activerecord (4.0.0) lib/active_record/query_cache.rb:43:in `rescue in call'
activerecord (4.0.0) lib/active_record/query_cache.rb:32:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__713349442__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.5) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
rack (1.5.5) lib/rack/content_length.rb:14:in `call'
rack (1.5.5) lib/rack/handler/webrick.rb:60:in `service'
C:/Ruby23/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
C:/Ruby23/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
C:/Ruby23/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'

数据库.yml

development:
adapter: mysql2
encoding: utf8
database: simple_cms_development
pool: 5
username: root
password: root
host: 127.0.0.1

Mysql正在运行并且密码正确。我尝试从命令行连接

G:\simple_cms>mysql -uroot -proot simple_cms_development
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

有人可以告诉我该错误的可能原因是什么吗

最佳答案

查看/etc/mysql/my.cnf 并检查 mysql 守护进程的绑定(bind)地址。它可能不绑定(bind)任何IP。然后它将使用unix套接字,顺便说一下,它比ip连接更快,...

绑定(bind)地址的选项名称是bind-address,如果没有匹配,则不会绑定(bind)到任何地址。还要查看指定 unix 套接字路径的套接字。您可以在database.yml中像这样使用套接字

development:
adapter: mysql2
encoding: utf8
database: simple_cms_development
username: root
password: root
host: 127.0.0.1
pool: 5
socket: /path/to/the/socket/mysql.sock

这应该适合你,

关于mysql - Rails Mysql ActiveRecord::ConnectionNotEstablished,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39113547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com