rake db:multi:migrate DATABASE=configuration error with JRuby, mysql, riak - mysql

JRuby 1.7.1 and Rails 3.2.11
In terminal I'm running "rake db:multi:migrate DATABASE=configuration" but I keep getting the error below meaning as far as I can tell that the configuration database is not being created.
Connecting to database specified by database.yml
(4.0ms) SET SQL_AUTO_IS_NULL=0
rake aborted!
The driver encountered an unknown error:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'configuration'
The specific steps I'm supposed to follow to get this set up are:
mysql.server start
mysql -uroot
create user 'funapp_test'#'localhost' IDENTIFIED BY 'funapp_test';
grant all privileges on *.* to 'funapp_test'#'localhost' with grant option;
create user 'funapp'#'localhost' IDENTIFIED BY '#sh4r3!';
grant all privileges on *.* to 'funapp'#'localhost' with grant option;
RAILS_ENV=test rake db:create
RAILS_ENV=development rake db:create
mysql -uroot funapp_test < db/structure.sql
mysql -uroot funapp < db/structure.sql
rake db:multi:migrate DATABASE=funapp
rake db:multi:migrate DATABASE=configuration
database.yml
development:
adapter: mysql
database: funapp
username: funapp
password: "#sh4r3!"
host: 127.0.0.1
pool: 5
xa: false
test: &test
adapter: mysql
database: funapp_test
username: funapp_test
password: "funapp_test"
host: 127.0.0.1
pool: 5
xa: false
configuration_development:
adapter: mysql
database: configuration
username: funapp
password: "#sh4r3!"
host: 127.0.0.1
pool: 5
xa: false
configuration_test:
adapter: mysql
database: configuration_test
username: funapp_test
password: "funapp_test"
host: 127.0.0.1
pool: 5
xa: false
Any ideas on what I can do to get this fixed? I've tried doing rake db:drop and rake db:migrate, as well as rake db:create:all (which gives me a Riak::Node configuration must include :source and :root keys. error) Thank you so much!

Figured it out, much simpler than I thought
mysql -uroot
create database configuration;
create database configuration_test;

Related

rake db:migrate ignores host parameter for production

When I try to run rake db:migrate RAILS_ENV=production I get an error because it tries to connect to localhost (error: Mysql2::Error: Access denied for user 'xxxx'#'10.0.0.7' (using password: NO))
This is my database.yml file:
production:
adapter: mysql2
encoding: utf8
pool: 5
host: long-amazon-aws-rds-instance-endpoint
database: xxxx_production
username: xxxxx
password: <%= ENV['XXXX_DATABASE_PASSWORD'] %>
when I run echo $XXXX_DATABASE_PASSWORD it gives me the correct password and when I run a mysql -uxxxxx -hlong-amazon-aws-rds-instance-endpoint -p and then enter my password I can connect to the RDS no problem. I also have the environment variable set for passenger and the app connects fine to it, so the RDS instance is definitely reachable.
Why is rake trying to use the local ip and not the hostname specified in database.yml
So turns out you have to wrap the production in quotes. If I run rake db:migrate RAILS_ENV="production" it works...

ERROR 1045 (28000): Access denied for user '<username>'#'localhost' (using password: YES)

I realize there are other similar questions, however I haven't found one that is exactly what I'm having. My issue is that I'm trying to access the Rails dbconsole but it's using the wrong user.
To explain, here's my database.yml:
development:
adapter: mysql2
host: localhost
database: db/development.mysql2
user: root
password: password
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
database: db/test.mysql2
host: localhost
user: root
password: password
pool: 5
timeout: 5000
production:
adapter: mysql2
database: db/production.mysql2
host: localhost
user: root
password: password
pool: 5
timeout: 5000
When I try and access the console by typing rails dbconsole, this is the result:
$ rails dbconsole
Enter password:
ERROR 1045 (28000): Access denied for user 'marshallsherman'#'localhost' (using password: YES)
I can log in to mysql by typing $ mysql -uroot -ppassword AND by typing $ mysql -umarshallsherman -ppassword. But when I try and log into the $ rails dbconsole it defaults to the "marashallsherman" user, and this is incorrect.
This seems like such a stupid question, however, I don't know how to change the "default" user for the dbconsole so that I can log in with the info that's in my database.yml file.
Help? I'm on Mac OS X 10.9.2
EDIT: I managed to get it so that I can log into the $ rails dbconsole, however, it's still logging me in as 'marshallsherman'#'localhost' -- I can't figure out how to switch it to log me in as 'root'#'localhost'.

How to connect Rails with MySQL? [duplicate]

This question already has answers here:
"Access Denied" when rails connects to Mysql
(3 answers)
Closed 8 years ago.
I have the following running correctly:
rails new simple
rails server (working)
rails generate controller demo index
mysql -u root -p and creating the database and assigning GRANT PRIVILIGES on the database is done.
Now the problem is, I used the Bitnami-RubyStack packages on my MAC 10.7. When I want to run rake db:schema:dump, I get this error:
bash-3.2$ rake db:schema:dump
rake aborted!
Access denied for user 'root'#'localhost' (using password: YES)
/Applications/rubystack-1.9.3-18/simple/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:schema:dump => environment
(See full trace by running task with --trace)
even if I run GRANT PRIVILEGES.
Also I checked the username and password on my DB.yml:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_development
pool: 5
username: root
password: something
socket: /tmp/mysql.sock
host: 127.0.0.1
In your database config
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_development
pool: 5
username: root
password: something
socket: /tmp/mysql.sock
host: 127.0.0.1
you should use either socket or host, not both. Since socket works for you (mysql -u root -p works), try using it with your app. If there's any permission problems or whatnot, you are going to have to create root#127.0.0.1 in your mysql console and use the host parameter.

Cannot run rake db:migrate - Access denied for user 'root'#'localhost' in MySQL

I am using mySQL and Rails 3.2 and I run into this problem: The error code is: "rake aborted! Access denied for user 'root'#'localhost' (using password: NO)"
I am particularly sure that my database.yml is configured correctly, as follow:
development:
adapter: mysql2
encoding: utf8
database: simple_cms_development
pool: 5
username: simple_cms
password: my_actual_password
socket: /tmp/mysql.sock
I am very confused as the error said access denied for user 'root'#'localhost'. Now I cannot run any command like rake, rake db:migrate.
I've gone through other similar questions on Stackoverflow like (Why my rake db:migrate throws error message?) but the answer does not solve my problem.

Redmine installation issues rake command issue, MySQL database issue?

I have somewhat of a complex issue involving several different programs including redmine, MySQL, Ruby, Ruby on Rails etc. This is on Windows XP.
I am following the redmine instructions here: http://www.redmine.org/projects/redmine/wiki/RedmineInstall
I am on step 5. where I am suppose to type RAILS_ENV=production rake db:migrate
When I type this in the command prompt and hit enter I get an error: "RAILS_ENV" is not a command blah blah.
So I reorder it to: rake db:migrate RAILS_ENV=production
This seems to work correct, but I get the following:
C:\redmine-1.2.1>rake db:migrate RAILS_ENV=production --trace
* Invoke db:migrate (first_time)
* Invoke environment (first_time)
* Execute environment
rake aborted!
Access denied for user 'redmine'#'localhost' (using password: YES)
C:/redmine-1.2.1/vendor/rails/activerecord/lib/active_record/connection_adapters
/mysql_adapter.rb:620:in `real_connect'
C:/redmine-1.2.1/vendor/rails/activerecord/lib/active_record/connection_adapters
/mysql_adapter.rb:620:in `connect'
C:/redmine-1.2.1/vendor/rails/activerecord/lib/active_record/connection_adapters
/mysql_adapter.rb:203:in `initialize'
C:/redmine-1.2.1/vendor/rails/activerecord/lib/active_record/connection_adapters
/mysql_adapter.rb:75:in `new'
Here is my database.yml file contents:
MySQL (default setup).
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: ****
encoding: utf8
development:
adapter: mysql
database: redmine_development
host: localhost
username: root
password:
encoding: utf8
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql
database: redmine_test
host: localhost
username: root
password:
encoding: utf8
test_pgsql:
adapter: postgresql
database: redmine_test
host: localhost
username: postgres
password: "postgres"
test_sqlite3:
adapter: sqlite3
database: db/test.sqlite3
I really need some direction here. It's almost like there is a problem with my users/passwords. I have changed the passwords not to contain "!" or any other special characters. I do have capital and lower case letters.
Any help would be greatly appreciated.
DemiSheep
So, you have created the 'redmine' mysql user with the password specified in database.yml?
Can you connect to this user using mysql client? (e.g. mysql -uredmine -pyourmysqlpassword)
Does the user have all required privileges?