Db:create gives "Unknown database"

I’m trying to install Typo 5.0.3 and “rake db:create” gives the
following error:

– cut here –
(in /Users/arungupta/samples/jruby/typo-5.0.3)
rake aborted!
#42000Unknown database ‘typo_dev’

(See full trace by running task with --trace)
– cut here –

I’m able to create other trivial Rails applications and db:create
database there.

-Arun


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

On Thu, May 29, 2008 at 1:52 AM, Arun G. [email protected]
wrote:

I’m able to create other trivial Rails applications and db:create
database there.

it’s because the default environnement is development.

Try :

rake db:create RAILS_ENV=‘production’

So the creation are in typo production database. You know how is this
base in config.database.yml

Is it mandatory to use production database ?

The command below should generate the development database, isn’t it ?

-Arun

On Wed, May 28, 2008 at 11:30 PM, Cyril M. [email protected]
wrote:

http://rubyforge.org/mailman/listinfo/typo-list


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

On Thu, May 29, 2008 at 4:24 PM, Arun G. [email protected]
wrote:

Is it mandatory to use production database ?

No it’s for your production mode. Because with the production
database, there are too production configuration about cache by
example. So it’s advise to use production environnement for a blog not
use for developpement.

The command below should generate the development database, isn’t it ?

This commande create the database. But your user are right for create it
?

Okay this is plain silly,

what does your config/database.yml show?

Which Adapter are you using SQLite3? MySQL?

If you are using MySQL please create the database, db:create does not
create the database for you.

… and if you are unaware of how to do that, then please read the
manual for whatever adapter you are using.

Is it mandatory to use production database ?

No it’s for your production mode. Because with the production
database, there are too production configuration about cache by
example. So it’s advise to use production environnement for a blog not
use for developpement.
Ok, I was trying it on my local so thought of trying the development
mode to begin with.

Even with production mode, I’m getting:

– cut here –
(in /Users/arungupta/samples/jruby/typo-5.0.3)
rake aborted!
#42000Unknown database ‘typo’

(See full trace by running task with --trace)
– cut here –

The command below should generate the development database, isn’t it ?

This commande create the database. But your user are right for create it ?
I’m using the database.yml bundled with Typo 5.0.3 and MySQL is also
default (username: root, password: ).

-Arun


Cyril M.
http://blog.shingara.fr


Typo-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/typo-list


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

Okay this is plain silly,
Sorry, but not working for me :frowning:

what does your config/database.yml show?

It is the one bundled with Typoe 5.0.3 and shown here:

login: &login
adapter: mysql
host: localhost
username: root
password:

development:
database: typo_dev
<<: *login

test:
database: typo_tests
<<: *login

production:
database: typo
<<: *login

Which Adapter are you using SQLite3? MySQL?
MySQL with JRuby

If you are using MySQL please create the database, db:create does not create
the database for you.
Hmmm …

~/testbed/jruby-1.1.2/bin/jruby -S rails foo -d mysql
cd foo
~/testbed/jruby-1.1.2/bin/jruby -S rake db:create

http://dev.rubyonrails.org/changeset/6849 also says so.

What am I missing ?

-Arun


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

Arun,

First you need to modify the database.yml so it has permission to
access typo_dev typo_tests or typo.

If you want to run with root that’s fine.

at a shell prompt type,

mysqladmin create typo
mysqladmin create typo_dev
mysqladmin create typo_tests

then you can try rake db:create

On Fri, May 30, 2008 at 2:49 AM, Arun G. [email protected]
wrote:

host: localhost
<<: *login

production:
database: typo
<<: *login

Which Adapter are you using SQLite3? MySQL?
MySQL with JRuby

With JRuby, I think that the Mysql adapter doesn’t work. You need use
: jdbcmysql

Test with change the line adapter : mysql by adapter : jdbcmysql
and install the gems jdbc-mysql activerecord-jdbcmysql-adapter.

Which Adapter are you using SQLite3? MySQL?
MySQL with JRuby

With JRuby, I think that the Mysql adapter doesn’t work. You need use
: jdbcmysql

Test with change the line adapter : mysql by adapter : jdbcmysql
and install the gems jdbc-mysql activerecord-jdbcmysql-adapter.
MySQL Ruby adapter has always worked for me on Mac OS X.

As I said above,

~/testbed/jruby-1.1.2/bin/jruby -S rails foo -d mysql
cd foo
~/testbed/jruby-1.1.2/bin/jruby -S rake db:create

creates foo_development database for me. Why do I have to create it
explicitly for Typo ?

-Arun


Cyril M.
http://blog.shingara.fr


Typo-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/typo-list


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

Arun G. wrote:

AIU the main point of db:create is to create the database. Since Rails
2.0, I’ve never use mysqladmin command to create the database and
always used db:create. I’m still confused why I need to explicitly
create the database using mysqladmin.
-Arun

Hi Arun,

No one here believes you? Well I do… had the same error. I found
several URLs of the same sort, like
http://justbarebones.blogspot.com/2008/05/rails-202-restful-authentication-and.html
and this very recent bug report:
http://rails.lighthouseapp.com/projects/8994/tickets/63-bug-rake-db-create-and-observers
However, I ended up giving up on rails and created my database manually.
It IS a bug in rails, maybe triggered by one of the plugins, who knows.
Since it only shows up at db creation time I thought it not worth
investigating further.

To all those doubters here, first, db:create IS supposed to create the
database. When I run it and the (empty!) schema exists it complains
about this fact. When the schema doesn’t exist I get the same error as
Arun. It’s just another bug in rails.

Michael

First you need to modify the database.yml so it has permission to access
typo_dev typo_tests or typo.

If you want to run with root that’s fine.
Yep, that’s fine with me since first I want to get the feel of Typo.

at a shell prompt type,

mysqladmin create typo
mysqladmin create typo_dev
mysqladmin create typo_tests

then you can try rake db:create
I know mysqladmin command.

AIU the main point of db:create is to create the database. Since Rails
2.0, I’ve never use mysqladmin command to create the database and
always used db:create. I’m still confused why I need to explicitly
create the database using mysqladmin.

-Arun

It is the one bundled with Typoe 5.0.3 and shown here:
<<: *login

Which Adapter are you using SQLite3? MySQL?
~/testbed/jruby-1.1.2/bin/jruby -S rails foo -d mysql

Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

!DSPAM:483f4f4c110161263019146!


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

Thanks Michael,

Your statement is bringing sanity back to me :slight_smile:

Since Rails 2.0 (now 2.1), I’ve always created database using
db:create. I was wondering why it just does not work with Typo but the
bug report seems to make some sense. Now the weird thing is that
config/environment.rb has:

config.active_record.observers = :email_notifier, :web_notifier

so the bug reports are not valid in this particular case. It seems
there is something more to it. Guess I’ll blog about it.

-Arun

On Thu, Jun 19, 2008 at 6:57 AM, Michael Hasenstein
[email protected] wrote:

[email protected]
http://rubyforge.org/mailman/listinfo/typo-list


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

Hi,

It wasn’t that I had any doubt that db:create should work, it was that
rake task is defined in rails, and not typo. So I felt it was more
rails related. Where it’s casued or ended, I don’t know.

it works for me with regular ruby 1.8.6, I don’t use jruby so I did
not test, but I assume that jruby is unrelated.

Unfortunately, I am a believer in testing w/ ruby only, as I have
found some unique problems using rubinus, YARV and jruby that do not
happen elsewhere…

When in doubt, try it the “normal” way, and if it works, backtrack and
find out where and why it’s failing.

… however for me personally I try to run a secure MySQL Server; so I
give each rails app it’s own login credentials, and db:create will/
would fail because I do not give it permission to create a database.
Which is why I find db:create rake task to be downright silly.

Thanks for listening, no reply necessary.

i’m having the same problem since yesterday, whin i updated
to 2.1.0. for me the problem is that this new version of
rake is loading the files in my ‘config/initializers’ directory,
and one of the files has database operations, so as the database
is not created yet the ‘db:create’ task halts. i commented
the db calls and the db was created normally.
anyone knows how to avoid this loading? or why rake
is now loading the appl context?

Arun G. wrote:

I’m trying to install Typo 5.0.3 and “rake db:create” gives the
following error:

– cut here –
(in /Users/arungupta/samples/jruby/typo-5.0.3)
rake aborted!
#42000Unknown database ‘typo_dev’

(See full trace by running task with --trace)
– cut here –

I’m able to create other trivial Rails applications and db:create
database there.

-Arun


Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

Hi. I just have the same problem yesterday.
Here is my notes so far:

Solving rake db:migrate error
Error:
$ rake db:migrate
(in /Users/johndoe/Sites/MyProject)
rake aborted!
#42000Unknown database ‘myDB’
/Users/johndoe/Sites/MyProject/rakefile:10
(See full trace by running task with --trace)

Solution:

  1. Open config/application.rb
  2. Comment all block related to
    if ActiveRecord::Base.connection.tables.include?(“countries”)
  3. Run the rake again
  4. Uncomment the if block

I hope it helps :slight_smile:

Regards,
Eric

Lark Dark wrote:

Arun G. wrote:

I’m trying to install Typo 5.0.3 and “rake db:create” gives the
following error:

– cut here –
(in /Users/arungupta/samples/jruby/typo-5.0.3)
rake aborted!
#42000Unknown database ‘typo_dev’

I am new to Rails and Ruby and I’ve had a similar problem with a remote
copy of mysql running on a non-dns server on my internal home network.
192.168.0.101 is my Win7 Ruby development environment and a mysql server
is running on 192.168.0.103 on a FreeBSD machine.

I have the following settings in database.yml:

development:
adapter: mysql
encoding: utf8
reconnect: false
database: myapp_development
pool: 5
username: mysql
host: !str “192.168.0.103”
password:
port: 3306

I had a number of problems connecting to mysql when both were installed
on Win7,
in fact so many that I moved the server to UNIX. Using SQLite works
fine, but
I wanted to try MySQL.

The first problem I had connecting was the IP address not being picked
up by
the YAML configuration file. After hours of haggling with various
things, I
found [!str “192.168.0.103”] works in converting the IP address to a
proper
string.

http://yaml.org/YAML_for_ruby.html was a useful resource, since I am new
to
it.

The second problem I had was in thinking “rake db:migrate” would create
the
database for me. But reading advice in this forum, I created it manually
and
that seemed to do the trick. Tables got created in it.

Most people here probably already know this stuff but I thought I would
post my
experience anyway since it has been an all-day affair to fix.

Allan Bowhill wrote:

Lark Dark wrote:

Arun G. wrote:

I’m trying to install Typo 5.0.3 and “rake db:create” gives the
following error:

– cut here –
(in /Users/arungupta/samples/jruby/typo-5.0.3)
rake aborted!
#42000Unknown database ‘typo_dev’

I am new to Rails and Ruby and I’ve had a similar problem with a remote
copy of mysql running on a non-dns server on my internal home network.
192.168.0.101 is my Win7 Ruby development environment and a mysql server
is running on 192.168.0.103 on a FreeBSD machine.

I have the following settings in database.yml:

development:
adapter: mysql
encoding: utf8

Oh, one more thing. To get the connections going I had to download an
older version of libmySQL.dll from Oracle’s website and installed it in
the /bin directory of my Ruby installation. The dll was version 5.1.x
and the server is also 5.1.x and I think that solved the connection
problem.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs