Felipe Marcon
Felipe Marcon

Reputation: 349

Rails - Mysql database already exists but it doesn't exist

I'm trying run a rake db:create and it says that the database already exists (I never created this database before, this a new project). When I run rake db:migrate it says "Unknown database". I checked the mysql database (show databases;) and that database really does not exist.

Anyone knows what is that? I searched for solutions but without success.

When I run rake db:create

rake db:create
Celluloid 0.17.3 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
adimax_development already exists
adimax_test already exists

When I run rake db:migrate

rake db:migrate
Celluloid 0.17.3 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
rake aborted!
Mysql2::Error: Unknown database 'adimax_development'

database.yml

development:
 adapter: mysql2
 encoding: utf8
 database: adimax_development
 pool: 5
 username: root
 password:

Error: Error image:

Upvotes: 2

Views: 3604

Answers (2)

Felipe Marcon
Felipe Marcon

Reputation: 349

I got solve this creating the database directly in mysql.

I entered in mysql with mysql -u root and than I run "CREATE DATABASE adimax_development;". After this I comeback to my application and run rake db:migrate and that worked.

Thanks to all those who have been willing to help.

Upvotes: -2

Prashant Patel
Prashant Patel

Reputation: 177

Try executing this command:

rake db:drop db:create db:migrate

Reference: https://stackoverflow.com/a/4116124/9336629

Upvotes: 5

Related Questions