Problem with database still sqlite3 and i want mysql

Hi all,
I am a beginner developer on Rails. Unfortunately I have problems with
the
database connection for a week! I read many articles, but still not work
properly.

The problem: If I start a new Rails app, and I type: rails app_name -d
database -> it still make me an adapter with sqlite3.

I use Ubunu 10.4. I installed Ruby, Gem, than Rails. I chekcked:
ruby -v -> 1.8.7
gem -v -> 1.3.5
rails -v -> getopt: invalid option – ‘v’ (I don’t understand this one,
it
should be different?)

I can start mysql monitoring, so it is installed and working well.

I reinstalled rails a few time, because first I forget
-include-dependencies, or sudo, but now it seems okay, and it really
makes
me the basic app - but not with mysql! I read much, but still cannot
solve
it, any help is welcome! :slight_smile:

Thanks a lot,
gezope

On Jun 2, 2010, at 1:39 PM, Gerő Zoltán wrote:

Hi all,
I am a beginner developer on Rails. Unfortunately I have problems with the database connection for a week! I read many articles, but still not work properly.

The problem: If I start a new Rails app, and I type: rails app_name -d database -> it still make me an adapter with sqlite3.

Are you literally typing “rails app_name -d database” or are you typing
“rails app_name -d mysql”?

I use Ubunu 10.4. I installed Ruby, Gem, than Rails. I chekcked:
ruby -v -> 1.8.7
gem -v -> 1.3.5
rails -v -> getopt: invalid option – ‘v’ (I don’t understand this one, it should be different?)

That should work on 2.3.8 at least (what i’ve got handy). “rails
–version” should also work.

Hello,
thanks for the answer!

Sorry, I mistyped, I wrote: ‘rails my_app -d mysql’
and it creates everything, but the yaml shows it has sqlite3. Or is it
normal? And I always have to change this file also if I typed ‘-d
mysql’?

(It also has 5 questions during the creation: do I wnt to rreally
overwrite the 3 dipatch, and 2 more files? I tired both y/n.
Rails running, but I’m afraid not properly: ‘-v’ and ‘–version’ also
gives getopt, Terminating…)

May I ask: if you start a new Rails project, and type this -d mysql,
than the yaml file still contains sqlite3? Or it should be different,
right?

Thanks a lot!
best regards,
gezope

On Wed, Jun 2, 2010 at 1:39 PM, GerÅ‘ Zoltán [email protected] wrote:

I use Ubunu 10.4. I installed Ruby, Gem, than Rails. I chekcked:

rails -v → getopt: invalid option – ‘v’ (I don’t understand this one, it
should be different?)

Yes, it should work.

I reinstalled rails a few time, because first I forget
-include-dependencies, or sudo, but now it seems okay

No, it doesn’t; the fact that it fails on a standard command-line option
means you can’t expect anything correct out of it.

I would get rid of that current Rails installation completely and start
from scratch.

Good luck.

Hassan S. ------------------------ [email protected]
twitter: @hassan

Thank you for all for your help, you are really helpful!

I uninstalled all gems from gem list. Than I removed gem and than
removed ruby.
Then:

  1. sudo apt-get install ruby ; ruby -v -> 1.8.7
  2. sudo apt-get install rubygems ; gem -v -> 1.3.5.
    3 sudo gem install rails ; rails -v or rails --version -> now gives me
    the proram raisl currently not installed. Immediately after install! I
    haven’t typed a clear yet!

If I try rails my_app : it works. With -d mysql: still sqlite 3 in
the .yaml file.

I reinstalled again. I also deleted everything from ubuntu software
center. Then the first 2 steps.
And then the 3. sudo gem install rails -include-dependencies.
Now this -get opt problem like in the beginning. But rails does not
work. :slight_smile: Neither with sqlite3.
Hopeless. Mysql still running. I should buy a Mac… :slight_smile:

Now I will remove, reinstall again, maybe one another way, include
dependencies or not, export path or not, I try all of the versions. If
anyone knows a way, which is coorectly works allways, than please put
it to some ubuntu forum also, because every page say different way.
Maybe only 5% of the developers have these problems - but very hard to
be in this 5%. :slight_smile:

Thx a lot again!
gezope

On Fri, Jun 4, 2010 at 6:30 PM, gezope [email protected] wrote:

Then:

  1. sudo apt-get install ruby ; ruby -v → 1.8.7
  2. sudo apt-get install rubygems ; gem -v → 1.3.5.
    3 sudo gem install rails ; rails -v or rails --version → now gives me
    the proram raisl currently not installed. Immediately after install! I
    haven’t typed a clear yet!

Just out of curiosity, I downloaded Ubuntu 10.4 and created a new
VirtualBox VM. I installed ruby and rubygems using the Synaptic GUI
package manager.

Here’s what followed:

hassan@coffee:~$ sudo gem install rails
[sudo] password for hassan:
Successfully installed rake-0.8.7
Successfully installed activesupport-2.3.8
Successfully installed activerecord-2.3.8
Successfully installed rack-1.1.0
Successfully installed actionpack-2.3.8
Successfully installed actionmailer-2.3.8
Successfully installed activeresource-2.3.8
Successfully installed rails-2.3.8
8 gems installed

hassan@coffee:~$ mkdir projects
hassan@coffee:~$ cd projects
hassan@coffee:~/projects$ rails -v
The program ‘rails’ is currently not installed. You can install it by
typing:
sudo apt-get install rails
hassan@coffee:~/projects$ gem list --local

*** LOCAL GEMS ***

actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
rack (1.1.0)
rails (2.3.8)
rake (0.8.7)
hassan@coffee:~/projects$ gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.3.5
  • RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
  • INSTALLATION DIRECTORY: /var/lib/gems/1.8
  • RUBY EXECUTABLE: /usr/bin/ruby1.8
  • EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-linux
  • GEM PATHS:
    • /var/lib/gems/1.8
    • /home/hassan/.gem/ruby/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:
    • http://gems.rubyforge.org/
      hassan@coffee:~/projects$ cd /var/lib/gems/1.8/bin
      hassan@coffee:/var/lib/gems/1.8/bin$ ls
      total 20
      drwxr-xr-x 2 root 4096 2010-06-05 10:27 ./
      drwxr-xr-x 7 root 4096 2010-06-05 10:27 …/
      -rwxr-xr-x 1 root 369 2010-06-05 10:27 rackup*
      -rwxr-xr-x 1 root 371 2010-06-05 10:27 rails*
      -rwxr-xr-x 1 root 367 2010-06-05 10:27 rake*
      hassan@coffee:/var/lib/gems/1.8/bin$ cd projects
      hassan@coffee:~$ export PATH=/var/lib/gems/1.8/bin:$PATH
      hassan@coffee:~$ which rails
      /var/lib/gems/1.8/bin/rails
      hassan@coffee:~$ rails -v
      Rails 2.3.8
      hassan@coffee:~$ rails project1
      create

      hassan@coffee:~$ rails project2 -d mysql
      create

      hassan@coffee:~$ cat project1/config/database.yml

SQLite version 3.x

gem install sqlite3-ruby (not necessary on OS X Leopard)

development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

hassan@coffee:~$ cat project2/config/database.yml

MySQL. Versions 4.1 and 5.0 are recommended.

Install the MySQL driver:

gem install mysql

On Mac OS X:

sudo gem install mysql – --with-mysql-dir=/usr/local/mysql

On Mac OS X Leopard:

sudo env ARCHFLAGS=“-arch i386” gem install mysql –

–with-mysql-config=/usr/local/mysql/bin/mysql_config

This sets the ARCHFLAGS environment variable to your native

architecture

On Windows:

gem install mysql

Choose the win32 build.

Install MySQL and put its /bin directory on your path.

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:
adapter: mysql
encoding: utf8
reconnect: false
database: project2_development
pool: 5
username: root
password:
host: localhost

hassan@coffee:~$

So, not knowing what could be messed up on your system, especially
after a lot of repeated install/uninstall cycles, you might want to try
a
complete OS reinstall…

HTH!

Hassan S. ------------------------ [email protected]
twitter: @hassan

On 6/5/10, Hassan S. [email protected] wrote:

Successfully installed activerecord-2.3.8
The program ‘rails’ is currently not installed. You can install it by
activesupport (2.3.8)

  • RUBYGEMS PLATFORMS:
    • :bulk_threshold => 1000
      hassan@coffee:/var/lib/gems/1.8/bin$ cd projects

MySQL. Versions 4.1 and 5.0 are recommended.

On Windows:

database: project2_development
pool: 5
username: root
password:
host: localhost

Sorry, didn’t see your post. Yes, that is how I had resolved it. But
as I mentioned in my previous post, I only install ruby from the
repositories. I download the rubygems archive and then install it
manually. That does not bring me the problem that occurrs when I
install from the repositories.

hassan@coffee:~$

So, not knowing what could be messed up on your system, especially
after a lot of repeated install/uninstall cycles, you might want to try a
complete OS reinstall…

Don’t think that will be necessary. Before I solved the problem, I had
done this and the problem persisted.

Regards,

Fidel.

I am also using Ubuntu 10.04 and it all works fine for me.

Don’t install gems from the repository. Here is what I did:

  1. sudo apt-get install ruby
  2. wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
  3. tar -xvzf rubygems-1.3.7.tgz
  4. cd rubygems
  5. ruby setup.rb
  6. gem install rails

and you should be set. Don’t forget to install mysql and sqlite3-ruby.
Don’t forget to install the development libraries for mysql and
sqlite3. This are from the repository using apt-get

When I installed rails from the repositories I ran into the same
problems you are running now. It couldn’t find teh application. I
don’t remember how I sorted it, but I know it had something to do with
it not being in the path. I now only install ruby from the
repositories. I manually download rubygems and then install it
manually.

Let me know if you still run into problems.

All the best,

Fidel.

On 6/6/10, gezope [email protected] wrote:

Your advice is fine; the 1,2,3,4 steps are okay (I am also new in
Linux, so i suggest 4. ‘cd rubygems’ you mean go to the new directory,
here it was ‘cd rubygems-1.3.7’ , let me know if I misunderstand it
please:))

Yes, this is what I meant.

(from here: RubyOnRails - Community Help Wiki )
Finally I stopped here, in the 5th point, please help me go on! (It is
important for me, to get involved this Ubuntu community - without
Rails it seems hopeless. :O)

you need to do in step 5 the following:

Don’t need to chmod the file. The permission denied meant that you
need to be root to have access to the path described.

Try this in step 5)

sudo ruby setup.rb

Try that and report back.

All the best,

Fidel.

Thanks a lot, unfortunately my problem hasn’t solved. But I found that
everything works well, just it was scary for a beginner. And still
strange a bit, but I will not spend more time with it, because all
other things are ok, so I did not find it too important - now I have
to change the DB on the server when I move the folders, that’s all.
Anyway: thank you for all, mostly for Fidel! :slight_smile:
gezope

Dear Fidel, thanks for your helpful answer! :slight_smile: The thing why I ask
further questions here, and not in private is: maybe later will have
the same problem, and then it will be searchable! :wink:

Your advice is fine; the 1,2,3,4 steps are okay (I am also new in
Linux, so i suggest 4. ‘cd rubygems’ you mean go to the new directory,
here it was ‘cd rubygems-1.3.7’ , let me know if I misunderstand it
please:))

After it: 5. ruby setup.rb says:

ERROR: While executing gem … (Errno::EACCES)
Permission denied: ~ /usr/local/lib/site_ruby/1.8/geuntlet_rubygems.rb

I tried chmod and sudo chmod 644 and then this location, but it says:
cannot access (here the filename).

After it I tried to give the path, but i think gem is not on my system
yet, so it is kinda useless, but I tried, maybe…
(from here: RubyOnRails - Community Help Wiki )
I tried this: export PATH=/var/lib/gems/1.8/bin:$PATH
After it still neither chmod or setup.rb runs.

I tried it 2 more time, once only from Synaptic :D, and then the same
way what u suggested (of course first delete every gem for gem list,
than remove gem, then remove ruby, than restart the procedure).

I also tried irb, than setup.rb, it says undefined local variable,
from the directory where it should be.

Finally I stopped here, in the 5th point, please help me go on! (It is
important for me, to get involved this Ubuntu community - without
Rails it seems hopeless. :O)

Thanks again, you already helped a lot! :slight_smile:
all the bests, bueno vista,
gezope