I am using rails 3.2 and mongoid.
I make these steps for setting my database:
// Add an Admin User (to the admin db)
use admin
db.addUser("theadmin", "anadminpassword")
// Use your database
use superuser
// Add a user (to your database)
db.addUser("John", "passwordForJohn")
// show all users:
db.system.users.find()
// add readonly user (kinda cool)
db.addUser("readonly", "passwordForJohn", true)
In my mongo.yml I have:
production:
host: localhost
port: 27017
username: John
password: passwordForJohn
database: namedatabase
You can see in http://www.mongodb.org/display/DOCS/Security+and+Authentication
My problem is that now I try run:
rake db:seed
I get now this error:
rake aborted!
Connection refused - connect(2)
How can I fix it?
The problem was fixed:
The problem was with solr server:
If you have solr server in your project:
1º Make sure that the Solr server is started before you seed:
rake sunspot:solr:start
rake sunspot:reindex
2º Run your seed:
rake db:seed
Regards
Related
What do I need to do to be able to run tests with a SQL Server 2008 database server using the gem activerecord-sqlserver-adapter?
I am able to connect to the development database just fine using a 32bit ODBC connection through dev settings in database.yml:
#SQL Server
development:
adapter: sqlserver
mode: odbc
dsn: <odbc_name>
username: <db_user>
password: <db_password>
host: <sql host>
I have started to setup some testing but run into an error when running:
rake db:test:prepare
Here is the error:
rake aborted!
ODBC::Error: 37000 (3708) [Microsoft][SQL Native Client][SQL Server]Cannot drop
the database 'master' because it is a system database.: DROP DATABASE [master]
Tasks: TOP => db:test:load => db:test:purge
(See full trace by running task with --trace)
This error doesn't make sense to me. Why is it trying to drop the master db?
My test setup in database.yml is exactly the same as my dev above except it points to a different odbc which points to a different database.
EDIT
I have noticed that when I run rake db:test:prepare the first step must be to delete the test database. So it knows what database it is supposed to use at first.
Why does it then try to delete the master?
Is this because when sql doesn't find the default database it gives the user master by default and rake db:test:prepare cannot create the users default db so it loops back to the beginning and tries to drop again?
I got this to work by specifying the name of the database in the test configuration:
# config/database.yml
...
test:
adapter: sqlserver
mode: odbc
dsn: <odbc_name>
database: <database_name>
username: <db_user>
password: <db_password>
...
I have PostgreSQL installed via this link and all seems good. I can use the GUI interface and I can see my databases but when I run rake db:migrate I get the following error:
$ rake db:migrate
(in /Users/tamer/Sites/sample)
rake aborted!
FATAL: password authentication failed for user "tamer"
(See full trace by running task with --trace)
Here is my database.yml file:
development:
adapter: postgresql
database: test
encoding: unicode
host: localhost
user: postgres
password: mypass
timeout: 5000
Where "mypass" is my password I set.
Here is a picture of it running
Any ideas what i am doing wrong?
Well something doesn't quite add up. The error message refers to a user "tamer" but the database.yml file has the "postgres" user. Are you sure this is the database.yml file that's being used? What happens when you try to log in with the GUI tool with either user?
I have my config/database.yml like this:
development:
adapter: postgresql
database: psql_dev
username: postgres
min_messages: WARNING
test:
adapter: sqlite3
database: db/test.sqlite3
min_messages: WARNING
When I run rake test:units, it reports an error:
rake aborted!
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Why didn't it connect to my test DB(db/test.sqlite3).
and, If I run the test like this rake test RAILS_ENV=test, it works well.
Isn't RAILS_ENV=test the default setting for rake test?
I'm running rails 2.3.5 with ruby 1.8.7, and my $RAILS_ENV is not defined in my shell.
What's happening is that rake test depends on rake db:test:prepare which will attempt to load the current schema from the development database. That's how the test database gets updated when a migration is run on the development database
do you have a test:units rake task? Run:
rake test
does that work? Also can you paste the output of:
rake -T | grep tests
I am using Rails v2.3. and MySQL v5.1
I created a new Rails environment named "special" by copy the config/environments/development.rb to config/environments/special.rb
Then, I defined the following thing in config/database.yml :
special:
adapter: mysql2
host: localhost
username: My_user_name
password: My_pwd
database: special_db
encoding: latin1
Then, I go to the command line to run the command:
$ RAILS_ENV=special rake db:create
also tried $rake db:create RAILS_ENV=special
I expect a new database named special_db should be created, but it isn't .
Why? Why I have created a new environment and run db:create in that environment, but database is not created? Am I missing something?
Have you created the database in MySQL?
mysqladmin create special_db
Are you sure that the username you are using have privileges to the database?
GRANT ALL PRIVILEGES ON special_db.* TO 'user'#'host'; FLUSH PRIVILEGES;
What is the output from the rake task? Have you tried running with the -t option? If so can you post the output?
When trying to run rake db:seed on my app, I get the error:
Database command 'count' failed: {"assertion"=>"unauthorized db:app_development lock type:-1 client:127.0.0.1", "assertionCode"=>10057, "errmsg"=>"db assertion failure", "ok"=>0.0}
I get the same error with db:drop
Mmy app is connecting to the DB fine, it's just these rake taks are failing, and I'm not sure wh. I dont think seeding should need admin privileges. Maybe it's a passenger issue?
You need to have the username and password set in mongoid.yml for rake tasks to be able to connect to your database.
Example:
production:
host: host-name
port: 27017
username: itsmeyo
password: supasecret
database: project_production
You can also have them set in environment variables, but they need to be set.
password: <%= ENV['MONGOID_PASSWORD'] %>