Redmine2.2.0启动报mysql连接错误
在虚拟机CentOS 5装了个dotProject后,又装了个redmine2.2.0,启动时发现前几天正常运行的Redmine启动不了了,控制台输出错误信息如下:
=> Booting WEBrick
=> Rails 3.2.9 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/lib/ruby/gems/1.8/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql_adapter.rb:411:in `real_connect': Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql::Error)
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql_adapter.rb:411:in `connect'
看错误信息是无法通过/tmp/mysql.sock连接mysql数据库,记得安dotProject时要安装php5,好像php5也是通过/tmp/mysql.sock连接的数据库,但是dotProject运行正常,通过查phpinfo()函数显示,MYSQL_SOCKET 指向的路径是/tmp/mysql.sock,用命令查看ls -l /tmp 没有发现mysql.sock文件,奇怪呀,没了mysql.sock文件php还能照样跑,ruby就不行了,报错:不能连接mysql。至于原因还要慢慢查找。
经过验证,解决redmine的这个错误,有两种方法可以采用
-
建立软链接:用find / -name mysql.sock 命令找到mysql.sock的绝对路径,例如 /var/lib/mysql/mysql.sock。建立软链接:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock.
-
更改redmine的配置文件database.yml,添加socket参数 :找到redmine所在的目录,进入config文件夹,编辑database.yml文件,加入socket = /var/lib/mysql/mysql.sock 例如
# MySQL (default setup). production: adapter: mysql database: redmine host: localhost username: root password: root encoding: utf8 socket: /var/lib/mysql/mysql.sock development: adapter: mysql database: redmine_development host: localhost username: root password: root encoding: utf8 socket: /var/lib/mysql/mysql.sock
相关命令:
查找指定目录下的软链接,如查找/tmp目录下的软链接
find /tmp -type l -ls
find /tmp -type l -exec ls -l '{}' \;
注意:l 是字母的l ,不是竖线!
上一篇: 将textarea实现自适应高度及IE下滚动条不出现的bug
下一篇: Python之数据重塑