简体   繁体   English

延迟作业-耙作业:清除原因“无法通过套接字'/tmp/mysql.sock'连接到本地MySQL服务器(2)

[英]Delayed Job - rake jobs:clear causes "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

My database.yml file: 我的database.yml文件:

production:
  adapter: mysql2
  database: app_production
  host: 127.0.0.1
  username: root
  password: 12345678
  port: 3306
  pool: 15
  timeout: 5000
  socket: /var/run/mysqld/mysqld.sock

(Removing the socket line does not help) (卸下插座线无济于事)

Path according to my.cnf: 根据my.cnf的路径:

/var/run/mysqld/mysqld.sock

Mysql is running because my app is up, but when I run: Mysql正在运行,因为我的应用已启动,但是当我运行时:

 rake jobs:clear

from the console, I get: 从控制台,我得到:

rake aborted!
Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/mysql2-0.3.18/lib/mysql2/client.rb:70:in `connect'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/mysql2-0.3.18/lib/mysql2/client.rb:70:in `initialize'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:87:in `connection'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/relation.rb:477:in `delete_all'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/querying.rb:8:in `delete_all'
/home/deploy/dispatch/shared/bundle/ruby/2.2.0/gems/delayed_job-4.0.6/lib/delayed/tasks.rb:4:in `block (2 levels) in <top (required)>'
Tasks: TOP => jobs:clear

Delayed job will take the database configuration associated with the rails environment your application is running in. 延迟的工作将采用与应用程序在其中运行的Rails环境关联的数据库配置。

If you just run rake jobs:clear , it'll run by default in development mode and will try to connect to your development database. 如果您仅运行rake jobs:clear ,它将默认在开发模式下运行,并尝试连接到您的开发数据库。 If you want delayed_job to connect to your production database, you need to set the environment accordingly, ie production: 如果想让delay_job连接到生产数据库,则需要相应地设置环境,即生产:

RAILS_ENV=production rake jobs:clear

By the way, keep the socket line in your database.yml , otherwise it'll default to /tmp/mysql.sock . 顺便说一句,将socket行保留在database.yml ,否则它将默认为/tmp/mysql.sock

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告:mysql_connect():无法通过套接字“ /tmp/mysql.sock”连接到本地MySQL服务器(2) - Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) `connect&#39;:无法通过套接字&#39;/tmp/mysql.sock&#39;(2)连接到本地MySQL服务器(Mysql2 :: Error) - `connect': Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error) 缺少 mysql.sock; 产生操作错误:(2002,“无法通过套接字连接到本地 MySQL 服务器‘/tmp/mysql.sock’(2)”) - Missing mysql.sock; yielding OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' - Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' Mysql2::Error: Can&#39;t connect to local MySQL server through socket &#39;/tmp/mysql.sock&#39; (2) - Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) - Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (2002,“无法通过套接字&#39;/tmp/mysql.sock&#39;(2)连接到本地MySQL服务器”) - (2002, “Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)”) Mountain Lion:无法通过套接字“ /tmp/mysql.sock”连接到本地MySQL服务器 - Mountain Lion: Can't connect to local MySQL server through socket '/tmp/mysql.sock' 无法通过FreeBSD上的套接字&#39;/tmp/mysql.sock&#39;(38)&#39;连接到本地MySQL服务器 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)' on FreeBSD 使用sourcemod时无法通过套接字&#39;/tmp/mysql.sock&#39;连接到本地MySQL服务器 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' when using sourcemod
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM