# MySQL error when running rake migrate

**URL:** <https://www.ruby-forum.com/t/mysql-error-when-running-rake-migrate/97099>\
**Category:** Rails\
**Created:** [July 4, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/mysql-error-when-running-rake-migrate/97099 "2006-07-04T22:07:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 4, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/mysql-error-when-running-rake-migrate/97099/1 "2006-07-04T22:07:41Z")

</div>

Running rails 1.1 and MySQL 5 on Kubuntu. I moved the same rails project  
from one machine to another. To set up the database I try to run `rake migrate` but I am greeted with the error/stack trace below. Any idea why  
this could be? It doesn’t seem to be a permissions problem–I can login  
to the database as my application just fine. I tried downgrading MySQL  
to v4.1 because that is the version that my other machine uses where  
`rake migrate` works, but no luck. I get the same error.

Thanks in advance to all who reply.

Chris

\*\* Invoke migrate (first\_time)  
\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute db:migrate  
rake aborted!  
Mysql::Error: Lost connection to MySQL server during query: SELECT  
version FROM schema\_info  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/connection\_adapters/abstract\_adapter.rb:120:in  
`log' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:185:in`execute’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/connection\_adapters/mysql\_adapter.rb:337:in  
`select' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:180:in`select\_one’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/migration.rb:306:in  
`current_version' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:323:in`current\_version’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/migration.rb:387:in  
`irrelevant_migration?' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:329:in`migrate’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/migration.rb:327:in  
`migrate' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:294:in`up’  
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/migration.rb:285:in  
`migrate' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/tasks/databases.rake:4 /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in`execute’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in`invoke’  
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in`invoke’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:in  
`invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in`each’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:in  
`invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in`invoke’  
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in`invoke’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in`run’  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7  
/usr/bin/rake:18

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 17, 2006, 3:19am UTC](https://www.ruby-forum.com/t/mysql-error-when-running-rake-migrate/97099/2 "2006-07-17T03:19:05Z")

</div>

Chris S. wrote:

> \*\* Invoke migrate (first\_time)  
> \*\* Invoke db:migrate (first\_time)  
> \*\* Invoke environment (first\_time)  
> \*\* Execute environment  
> \*\* Execute db:migrate  
> rake aborted!  
> Mysql::Error: Lost connection to MySQL server during query: SELECT  
> version FROM schema\_info

I’m having the exact same problem running migrations against MySQL 5 on  
Ubuntu from Rails on my Mac OSX. I’ve attempted to trace down the  
problem without much luck. Anyone have any ideas?

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 20, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/mysql-error-when-running-rake-migrate/97099/3 "2006-07-20T19:02:17Z")

</div>

uOn Mon, Jul 17, 2006 at 03:19:05AM +0200, Chris D. wrote:

> I’m having the exact same problem running migrations against MySQL 5 on  
> Ubuntu from Rails on my Mac OSX. I’ve attempted to trace down the  
> problem without much luck. Anyone have any ideas?

I think this is due to the MySQL connector. Use :  
gem install mysql to fix it.

## At least it did the last time I had this problem.

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 21, 2006, 7:03am UTC](https://www.ruby-forum.com/t/mysql-error-when-running-rake-migrate/97099/4 "2006-07-21T07:03:43Z")

</div>

I’m having the same problem with Windows (so now we have all main  
operating  
systems). Though I can connect to the database via phpMyAdmin for  
example,  
it does not work for ‘rake db:migrate’.

‘gem install mysql’ didn’t fix it, either.

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 26, 2006, 6:26am UTC](https://www.ruby-forum.com/t/mysql-error-when-running-rake-migrate/97099/5 "2006-07-26T06:26:58Z")

</div>

Hi,

I am having the same problem with my MS environment. I took the exact  
same project files and copied them to a linux host. rake migrate runs  
without error under linux. So there’s a workaround; copy your files to a  
linux host and run migrate from there. It is not pretty but it worked.
