I’ve created a db. Well… running ‘rails console’ and testing for
the existence of users and other resources works, so I’d infer that my
db has been created. But it’s not in my db directory, or in the root
directory… where could it be?
I recently tried getting mysql2 to work with my rails 3.0.3 app. I’m
on windows, and ever since the switch from sqlite3 to mysql2 (I
changed my database.yml to look like below) I’ve gotten this
confusion.
Even worse, now when I run ‘rails server’ the page literally takes
forever to load!! Hitting ctrl + c to stop the server makes the cmd
say “going to shutdown …” but it never does, so I have to manually
close the window and reopen the command line.
Oh I just opened my HeidiSQL program and found that all these
databases an be found there! All the tables and stuff can be viewed
there…how nice. Except…I still don’t understand WHERE these dbs
are…how does mysql2 handle them? How come they’re not found in my
application when I look through all my directories e.g. db, config,
app, etc.? It bothers me…
And I guess the more pressing issue now is WHY rails server goes so
slowwwwwww! Is it possible that too many dbs can make it that way?
So basically 1) why is rails server so slow/not working and 2) WHERE
are these dbs on my computer REALLY and how come they’re not in my
app’s directory?
as I know this is true about DBs. And one more thing about it: if you
keep your migrating files, then you can easily migrate on your server
later, and it will create all the databases for you, so it won’t be
problem if you have another type of DB in production then development.
Try this: gem install thin (or gem install mongrel also good),
then write it to your Gemfile: gem ‘thin’,
then from command line: ‘rails server -thin’
it will be faster then Webrick, the default server.
It’s in MySQL’s data directory, the location of which is set in your
MySQL configuration. SQLiite works fundamentally differently from most
other DBs, in that it puts the whole DB in a single file, which is nice
and portable, but runs into concurrency issues. MySQL and other DBs
locate all DBs centrally, and use multiple files to represent one DB.
You normally shouldn’t need to worry about where your MySQL DBs live.
Thanks!!! This is really helpful - it makes sense now.
I’ve created a db. Well… running ‘rails console’ and testing for
the existence of users and other resources works, so I’d infer that my
db has been created. But it’s not in my db directory, or in the root
directory… where could it be?
It’s in MySQL’s data directory, the location of which is set in your
MySQL configuration. SQLiite works fundamentally differently from most
other DBs, in that it puts the whole DB in a single file, which is nice
and portable, but runs into concurrency issues. MySQL and other DBs
locate all DBs centrally, and use multiple files to represent one DB.
You normally shouldn’t need to worry about where your MySQL DBs live.
Try this: gem install thin (or gem install mongrel also good),
then write it to your Gemfile: gem ‘thin’,
then from command line: ‘rails server -thin’
it will be faster then Webrick, the default server.
Gem list also says that I have “thin (1.2.7 x86-mingw32)” so I should
have thin now too.
HOWEVER, after adding
gem ‘eventmachine’, ‘0.8.1’
gem ‘thin’
to the gemfile and running bundle update, I get this error:
C:\Users\Family\workspace\beesl>bundle update
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
[etc…]
Using daemons (1.1.0)
Installing eventmachine (0.8.1) with native extensions C:/Ruby187/lib/
ruby/site_ruby/1.8/rubygems/installer.rb:483:in `
d to build gem native extension. (Gem::Installer::ExtensionBuildError)
C:/Ruby187/bin/ruby.exe extconf.rb
checking for windows.h… yes
checking for winsock.h… yes
checking for main() in -lkernel32… yes
checking for main() in -lrpcrt4… yes
checking for main() in -lgdi32… yes
checking for main() in -lssleay32… no
creating Makefile
make
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
Fatal: ‘ruby.h’ does not exist - don’t know how to make it
Gem files will remain installed in C:/Ruby187/lib/ruby/gems/1.8/gems/
eventmachine-0.8.1 for inspection.
Results logged to C:/Ruby187/lib/ruby/gems/1.8/gems/eventmachine-0.8.1/
ext/gem_make.out
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb:
446:in each' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb: 446:in build_extensions’
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb:
198:in install' from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/ bundler/source.rb:95:in install’
from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/
bundler/installer.rb:55:in run' from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/ bundler/spec_set.rb:12:in each’
from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/
bundler/spec_set.rb:12:in each' from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/ bundler/installer.rb:44:in run’
from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/
bundler/installer.rb:8:in install' from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/ bundler/cli.rb:271:in update’
from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/
bundler/vendor/thor/task.rb:22:in send' from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/ bundler/vendor/thor/task.rb:22:in run’
from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/
bundler/vendor/thor/invocation.rb:118:in invoke_task' from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/ bundler/vendor/thor.rb:246:in dispatch’
from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/
bundler/vendor/thor/base.rb:389:in start' from C:/Ruby187/lib/ruby/gems/1.8/gems/bundler-1.0.7/bin/ bundle:13 from C:/Ruby187/bin/bundle:19:in load’
from C:/Ruby187/bin/bundle:19
Running “rails server -thin” gives these errors:
C:\Users\Family\workspace\beesl>rails server -thin
Could not find gem ‘eventmachine (= 0.8.1, runtime)’ in any of the gem
sources listed in your Gemfile.
Try running bundle install.
I don’t recommend using mysql2 gem right now. It still has many
problems, especially with (invalid date) in numerous cases. I use the
normal mysql gem right now with windows and rails 3.0.3 and ruby 1.9.2.
(because you are windows and developing in windows)
You also have to replace mysql2 in the database.yml with mysql for the
adpater types. I also specify mysql in my Gemfile and then run bundle
install.
There are numerous issues still at large for mysql2.
Also I recommend using mongrel as well.
Place => gem ‘mongrel’, ‘>= 1.2.0.pre2’
… in your Gemfile
used with Ruby 1.9.2 on Windows (no other files necessary)
use bundle install to install mongrel
once mongrel is installed use “rails server” not “mongrel_rails start”
to start your server.
I develop many rails apps on Windows, Linux, and Mac. I like being
familiar with all of the environments. Windows is by far the most
difficult to setup and use with Ruby and RoR, but there are some
advantages with Windows installations (Windows 7 especially) that you
don’t get with the other OSs. It involves invoking PowerShell
scripting. But, that’s another disussion entirely.
Wait com’on there must be a way to get this mysql2 database to work
quickly with rails server…
And I’ve never come across the invalid date error you described.
Something…maybe???
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.