Forum: Typo db:create gives "Unknown database"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (Guest)
on 2008-05-29 01:59
(Received via mailing list)
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
2fd0206c71a1b22a9cc6293f38537461?d=identicon&s=25 Cyril Mougel (shingara)
on 2008-05-29 08:31
(Received via mailing list)
On Thu, May 29, 2008 at 1:52 AM, Arun Gupta <arun.gupta@gmail.com>
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
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (Guest)
on 2008-05-29 16:25
(Received via mailing list)
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 Mougel <cyril.mougel@gmail.com>
wrote:
>>
>
> http://rubyforge.org/mailman/listinfo/typo-list
>



--
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta
2fd0206c71a1b22a9cc6293f38537461?d=identicon&s=25 Cyril Mougel (shingara)
on 2008-05-29 17:01
(Received via mailing list)
On Thu, May 29, 2008 at 4:24 PM, Arun Gupta <arun.gupta@gmail.com>
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
?
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (Guest)
on 2008-05-29 18:14
(Received via mailing list)
>> 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: <blank>).

-Arun

>
>
> --
> Cyril Mougel
> http://blog.shingara.fr
> _______________________________________________
> Typo-list mailing list
> Typo-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/typo-list
>



--
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta
E8c366546962a603b831e66bc7798a7d?d=identicon&s=25 Scott Likens (Guest)
on 2008-05-29 21:13
(Received via mailing list)
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.
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (Guest)
on 2008-05-30 16:16
(Received via mailing list)
> Okay this is plain silly,
Sorry, but not working for me :(

>
> 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
E8c366546962a603b831e66bc7798a7d?d=identicon&s=25 Scott Likens (Guest)
on 2008-05-30 17:52
(Received via mailing list)
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
2fd0206c71a1b22a9cc6293f38537461?d=identicon&s=25 Cyril Mougel (shingara)
on 2008-05-30 17:52
(Received via mailing list)
On Fri, May 30, 2008 at 2:49 AM, Arun Gupta <arun.gupta@gmail.com>
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.
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (Guest)
on 2008-05-30 18:04
(Received via mailing list)
>>>
>>> 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 Mougel
> http://blog.shingara.fr
> _______________________________________________
> Typo-list mailing list
> Typo-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/typo-list
>



--
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (Guest)
on 2008-05-30 18:20
(Received via mailing list)
> 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
303f7b66221b4c70b15d2761699af90b?d=identicon&s=25 Michael Hasenstein (hasenstein)
on 2008-06-19 15:57
Arun Gupta 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-20...
and this very recent bug report:
http://rails.lighthouseapp.com/projects/8994/ticke...
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
268f57c236bb50c0f6e12ac38adc9d81?d=identicon&s=25 Arun Gupta (Guest)
on 2008-06-19 20:09
(Received via mailing list)
Thanks Michael,

Your statement is bringing sanity back to me :)

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
<ruby-forum-incoming@andreas-s.net> wrote:
>
>
> Typo-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/typo-list
>



--
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta
E8c366546962a603b831e66bc7798a7d?d=identicon&s=25 Scott Likens (Guest)
on 2008-06-20 01:41
(Received via mailing list)
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.
96fc3b82ceb54945fecca2fbdddd85a2?d=identicon&s=25 Py Jay (ppjunty)
on 2008-06-25 00:00
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?
Ca60fdd835b147b250ab0e1053952023?d=identicon&s=25 Lark Dark (ericfer)
on 2009-02-05 12:32
Arun Gupta 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 :)

Regards,
Eric
5e29e59173103b21d8872306c21f3894?d=identicon&s=25 Allan Bowhill (kosmos)
on 2010-08-23 05:31
Lark Dark wrote:
> Arun Gupta 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: <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.
5e29e59173103b21d8872306c21f3894?d=identicon&s=25 Allan Bowhill (kosmos)
on 2010-08-23 05:37
Allan Bowhill wrote:
> Lark Dark wrote:
>> Arun Gupta 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 topic is locked and can not be replied to.