详细解决方案
rake db:migrate为什么出现Mysql:Error: query: not connected异常
热度:551 发布时间:2016-05-06 04:23:28
网上也没有搜到相关问题,请高手帮忙
trace如下:
C:\Users\Administrator\Documents\NetBeansProjects\MyDigger>rake db:migrate --trace
(in C:/Users/Administrator/Documents/NetBeansProjects/MyDigger)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
Mysql::Error: query: not connected: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:320:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `create_table'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:473:in `create_table'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:320:in `initialize_schema_migrations_table'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/migration.rb:436:in `initialize'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/migration.rb:400:in `new'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/migration.rb:400:in `up'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/migration.rb:383:in `migrate'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/tasks/databases.rake:116
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/Ruby/bin/rake:19:in `load'
C:/Ruby/bin/rake:19
------解决方案--------------------
错误提示数据库没有连接上。
1、mysql数据库开了吗
2、database.yml 文件打开看看,是不是数据的配置没有配置好
------解决方案--------------------
根据这个提示
CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
去你的数据库看下是不是这个表没有建立或者有问题。建议你删除这个表后再migrate
------解决方案--------------------
如果是初学,建议用sqlite3作为你的development DataBase
------解决方案--------------------
这是因为新版mysql的客户端连接库对rails 2.2的支持不够好导致的,解决办法是使用旧版的客户端连接库,也就是把旧版mysql的libmySQL.dll文件(该文件在mysql安装目录的bin文件夹下面)复制到ruby目录下的bin文件夹中就可以解决这个问题了。
外国论坛上有人使用这个配置可以正常解决:Ruby 1.8.6, Rails 2.3.3, mysql 5.1.33
我的配置是:Ruby 1.8.6, Rails 2.3.2, mysql 5.0.67
相关解决方案
- mysql 简单化 or能否实现
- 请问registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister
- 大神们开始觅错啦!org.hibernate.exception.SQLGrammarException: could not execute query
- MySQL 5.5 Command Line Client 窗口1输密码就退出
- java报错Syntax error on token "return" invalid Type解决方案
- The server encountered an internal error () that prevented it from fulfilling th解决方案
- 请问上Linux平台上怎么搭建JDK \TOMCAT\MYSQL
- 在LINUX上配置 MySQL 开机自动 启动
- 'Update Progress' has encountered a problem An internal error has occurred解决方案
- mysql 转 orocle java ssh项目一条 sql 句不通!
- hibernate中Query query=session.createQuery的有关问题
- JSP向SQL数据库中写下数据时提示:Network error IOException: Connection refused: connect
- Error creating bean with name 'sessionFactory' defined in ServletContext resourc解决方法
- servlet+jquery1.4.2(ajax error?)解决方案
- Parse error in application web.xml,该如何解决
- java itext导出报Connection reset by peer: socket write error,该怎么处理
- jsp中的注册登录系统(mysql)
- Error reading resource: com/user/User.hbm.xml,该怎么解决
- fatal error; call to a member function query() on a non-object异常求回答啊 php+sqlite
- Error creating bean with name 'sessionFactory' defined in class path resource解决方法
- 大家帮帮忙呀The server encountered an internal error () that prevented it解决方法
- 上了个 MySQL 5.5.25 但是安装时出错了
- 求jsp博客源代码mvc+mysql,该如何解决
- java mysql 中文乱码有关问题
- 【100分】怎么监控多台服务器的log,alert,error
- SOS-(奇怪现象)服务器暂不可用500 internal server error,该怎么解决
- tomcat没法运行Could not publish to the server. Error while expanding
- JSF中javax.faces.el.PropertyNotFoundException: Error getting property的有关问题
- 请教各位,使用PreparedStatement mysql 数据库 不回滚,盼望解答。多谢。 具体如上
- Syntax error on token "{" { expected after this token,该怎么解决