Can't migrate schema

Hello all,
I’m a Ruby noobie, so please bear with me. I’ve recently switched to
Ubuntu and have installed ruby using the package manager. I then
installed gem, and used it to install rails and its dependencies.

I ran the rails command to create a website. I used the generator to
create a migration task and tried to run it with the following command.

rake migrate --trace

This produced the following trace:

(in /home/wgant/user/ruby/HoshinWeb)
** 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
/home/wgant/user/ruby/HoshinWeb/config/…/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
log' /home/wgant/user/ruby/HoshinWeb/config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:185:inexecute’
/home/wgant/user/ruby/HoshinWeb/config/…/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:337:in
select' /home/wgant/user/ruby/HoshinWeb/config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:180:inselect_one’
/home/wgant/user/ruby/HoshinWeb/config/…/vendor/rails/activerecord/lib/active_record/migration.rb:306:in
current_version' /home/wgant/user/ruby/HoshinWeb/config/../vendor/rails/activerecord/lib/active_record/migration.rb:323:incurrent_version’
/home/wgant/user/ruby/HoshinWeb/config/…/vendor/rails/activerecord/lib/active_record/migration.rb:387:in
irrelevant_migration?' /home/wgant/user/ruby/HoshinWeb/config/../vendor/rails/activerecord/lib/active_record/migration.rb:329:inmigrate’
/home/wgant/user/ruby/HoshinWeb/config/…/vendor/rails/activerecord/lib/active_record/migration.rb:327:in
migrate' /home/wgant/user/ruby/HoshinWeb/config/../vendor/rails/activerecord/lib/active_record/migration.rb:294:inup’
/home/wgant/user/ruby/HoshinWeb/config/…/vendor/rails/activerecord/lib/active_record/migration.rb:285:in
migrate' /home/wgant/user/ruby/HoshinWeb/config/../vendor/rails/railties/lib/tasks/databases.rake:4 /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:inexecute’
/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:ininvoke’
/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:ininvoke’
/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:ineach’
/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:ininvoke’
/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:ininvoke’
/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:inrun’
/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/usr/bin/rake:18

I’ve set up my database correctly in the database.yml file using the
same username and database name I use to connect with MySQL
Administrator. The database is currently empty (no schema table or
anything). Is this the problem or am I missing something else?

Thanks,
Will


All-new Yahoo! Mail - Fire up a more powerful email and get things done
faster.

Will G. wrote:

rake aborted!
Mysql::Error: Lost connection to MySQL server during query: SELECT

Did you configure a database server in config/database.yml?

Eric

Yes. I have the following listed in my config file

development:
adapter: mysql
database: MyWeb_dev
username: root
password: password
host: localhost

Any thoughts? This is the same info I use to connect to the database
currently.

Eric A. [email protected] wrote:
Will G. wrote:

rake aborted!
Mysql::Error: Lost connection to MySQL server during query: SELECT

Did you configure a database server in config/database.yml?

Eric

(What is best in life?) To crush your enemies, see them driven before
you, and to hear the lamentations of the women. - Conan the Barbarian


All-new Yahoo! Mail - Fire up a more powerful email and get things done
faster.

It will create it with the first migration.

can you connect from command line?

Craig

Is there something special I need to do to the database to get it ready
for migrations? I noticed that it is using a table to store the schema
version. Such a table does not exist in my database.

Will G. [email protected] wrote: Yes. I have the following
listed in my config file

development:
adapter: mysql
database: MyWeb_dev
username: root
password: password
host: localhost

Any thoughts? This is the same info I use to connect to the database
currently.

Eric A. [email protected] wrote:
Will G. wrote:

rake aborted!
Mysql::Error: Lost connection to MySQL server during query: SELECT

Did you configure a database server in config/database.yml?

Eric


All-new Yahoo! Mail - Fire up a more powerful email and get things done
faster.


Get your email and more, right on the new Yahoo.com

Yep. I can connect that way. However, now when I try to run
rake migrate
I get the following message
No such file or directory - /tmp/mysql.sock

This leads me to believe that something is configured incorrectly. Any
thoughts?

Craig W. [email protected] wrote:
It will create it with the first migration.

can you connect from command line?

Craig

On Sat, 2006-09-09 at 14:15 -0700, Will G. wrote:

      username: root
            > Mysql::Error: Lost connection to MySQL server during
            All-new Yahoo! Mail - Fire up a more powerful email
            and get things done faster.
            
            ______________________________________________________
            Get your email and more, right on the MailScanner has
            detected a possible fraud attempt from
            "us.rd.yahoo.com" claiming to benew Yahoo.com 
            >                 

(What is best in life?) To crush your enemies, see them driven before
you, and to hear the lamentations of the women. - Conan the Barbarian


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great
rates starting at 1¢/min.

Does /tmp/mysqlsock exist? Are you on Macintosh? Linux? Windows?

where is my.cnf?

When you connect from command line, do you specify a port # ? i.e. 3306

I’m on Ubuntu Linux and the file does not exist. I don’t specify a port
or anything when I connect on the command line. Do you think I should
re-install MySQL to see if that helps?

Craig W. [email protected] wrote:
Does /tmp/mysqlsock exist? Are you on Macintosh? Linux? Windows?

where is my.cnf?

When you connect from command line, do you specify a port # ? i.e. 3306

On Sat, 2006-09-09 at 15:28 -0700, Will G. wrote:

    store the
    > host: localhost
    > 
    > Did you configure a database server in
    > config/database.yml?
    > 

(What is best in life?) To crush your enemies, see them driven before
you, and to hear the lamentations of the women. - Conan the Barbarian


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
countries) for 2¢/min or less.

Include that in your database.yml file…

socket: /var/run/mysqld/mysqld.sock

Craig

The socket file being used when I connect via SQL Admin is
/var/run/mysqld/mysqld.sock

Is there a config file somewhere for ruby where this information could
be stored incorrectly?

Will G. [email protected] wrote: I’m on Ubuntu Linux and the
file does not exist. I don’t specify a port or anything when I connect
on the command line. Do you think I should re-install MySQL to see if
that helps?

Craig W. [email protected] wrote:
Does /tmp/mysqlsock exist? Are you on Macintosh? Linux? Windows?

where is my.cnf?

When you connect from command line, do you specify a port # ? i.e. 3306

On Sat, 2006-09-09 at 15:28 -0700, Will G. wrote:

    store the
    > host: localhost
    > 
    > Did you configure a database server in
    > config/database.yml?
    > 

Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+
countries) for 2¢/min or less.


Do you Yahoo!?
Get on board. You’re invited to try the new Yahoo! Mail.

Close…
Now it’s giving me the following error again:

rake aborted!
Mysql::Error: Lost connection to MySQL server during query: SELECT
version FROM schema_info

Will

Craig W. [email protected] wrote:
Include that in your database.yml file…

socket: /var/run/mysqld/mysqld.sock

Craig

On Sat, 2006-09-09 at 17:26 -0700, Will G. wrote:

            > thoughts?
            > On Sat, 2006-09-09 at 14:15 -0700, Will G. wrote:
            > > Yes. I have the following listed in my config file
            > > database currently.
            > > config/database.yml?
            Do you Yahoo!?
            Get on board. You're invited to try the new Yahoo!
            Mail.
            >                 

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail.

Could the new problem be related to this?

http://dev.rubyonrails.org/ticket/4749

Craig W. [email protected] wrote:
Include that in your database.yml file…

socket: /var/run/mysqld/mysqld.sock

Craig

On Sat, 2006-09-09 at 17:26 -0700, Will G. wrote:

            > thoughts?
            > On Sat, 2006-09-09 at 14:15 -0700, Will G. wrote:
            > > Yes. I have the following listed in my config file
            > > database currently.
            > > config/database.yml?
            Do you Yahoo!?
            Get on board. You're invited to try the new Yahoo!
            Mail.
            >                 

(What is best in life?) To crush your enemies, see them driven before
you, and to hear the lamentations of the women. - Conan the Barbarian


All-new Yahoo! Mail - Fire up a more powerful email and get things done
faster.

Why - are you editing environment.rb?

Craig

Apparently I overlooked that one. It’s giving me the following options.
Which do I take?

  1. mysql 2.7.1 (mswin32)
  2. mysql 2.7 (ruby)
  3. mysql 2.6 (ruby)
  4. mysql 2.5.1 (ruby)
  5. Cancel installation

I would think #2, but I wanted to check before I did anything. I’m
running MySQL 5.0.

Craig W. [email protected] wrote:
did you ‘gem install mysql’ ? (as root or via sudo?)

Craig

On Sat, 2006-09-09 at 19:13 -0700, Will G. wrote:

    > Is there a config file somewhere for ruby where this
    > 
    > On Sat, 2006-09-09 at 15:28 -0700, Will G. wrote:
    > > 
    > database to
    > > > development:
    > > > Eric A. wrote:
    > 
    > Mail.
    > > 
    
    
    
    ______________________________________________________________
    Do you Yahoo!?
    Everyone is raving about the all-new Yahoo! Mail.
    >         

Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great
rates starting at 1¢/min.

2 sounds like the winner

Craig

did you ‘gem install mysql’ ? (as root or via sudo?)

Craig

I tried this:
sudo gem install mysql --include-dependencies

and got the following:

Building native extensions. This could take a while…
extconf.rb:1:in `require’: no such file to load – mkmf (LoadError)
from extconf.rb:1

ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7
for inspection.

Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

The file in question is empty.

Craig W. [email protected] wrote:
2 sounds like the winner

Craig

On Sat, 2006-09-09 at 19:48 -0700, Will G. wrote:

I would think #2, but I wanted to check before I did anything. I’m
> Now it’s giving me the following error again:
> Include that in your database.yml file…
> information could
> >
> > On Sat, 2006-09-09 at 15:28 -0700, Will G. wrote:
> > >
> > database to
> > > > development:
> > > > Eric A. wrote:
> >
> > Mail.

    ______________________________________________________________
    Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.
    Great rates starting at 1¢/min.
    >         

(What is best in life?) To crush your enemies, see them driven before
you, and to hear the lamentations of the women. - Conan the Barbarian


Stay in the know. Pulse on the new Yahoo.com. Check it out.

On Fedora Core I’ve never had any luck using gem to install the Ruby
MySql plugin. But it always works when I use yum (Fedora package
manger). I suggest you track down the Ruby MySql package for your
system and install it that way.

Aaron

Hi, I also have the same problem as you. Do you mind telling me how you
fix it? I tried the gem install mysql but it doesn’t work.

Thanks,
Erwin

That fixed it. What a day!

Thanks to everyone for helping and putting up with me. I appreciate it.

Aaron B. [email protected] wrote: On Fedora Core I’ve never had
any luck using gem to install the Ruby MySql plugin. But it always
works when I use yum (Fedora package manger). I suggest you track down
the Ruby MySql package for your system and install it that way.

Aaron

On Sep 9, 2006, at 9:15 PM, Will G. wrote:

I tried this:
sudo gem install mysql --include-dependencies

and got the following:

Building native extensions. This could take a while…
extconf.rb:1:in `require’: no such file to load – mkmf (LoadError)
from extconf.rb:1

ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7
for inspection.

Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

The file in question is empty.

Craig W. [email protected] wrote:
2 sounds like the winner

Craig

On Sat, 2006-09-09 at 19:48 -0700, Will G. wrote:

I would think #2, but I wanted to check before I did anything. I’m
> Now it’s giving me the following error again:
> Include that in your database.yml file…
> information could
> >
> > On Sat, 2006-09-09 at 15:28 -0700, Will G. wrote:
> > >
> > database to
> > > > development:
> > > > Eric A. wrote:
> >
> > Mail.

    ______________________________________________________________
    Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.
    Great rates starting at 1¢/min.
    >         

Stay in the know. Pulse on the new Yahoo.com. Check it out.

(What is best in life?) To crush your enemies, see them driven before
you, and to hear the lamentations of the women. - Conan the Barbarian


Stay in the know. Pulse on the new Yahoo.com. Check it out.