简体   繁体   中英

Unable to rake db:migrate in production

I have created a user and granted it full access to the production database:

mysql> show grants for 'myuser'@'localhost';
+-----------------------------------------------------------------------------------------------------------------+
| Grants for myuser@localhost                                                                                   |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'myuser'@'localhost' IDENTIFIED BY PASSWORD '*xxxxxxxx' |
| GRANT ALL PRIVILEGES ON `myapp_production`.* TO 'myuser'@'localhost'                                       |
+-----------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

But when I rake db:migrate , I get:

** [out :: mydomain.com] Mysql2::Error: Access denied for user 'myuser'@'localhost' (using password: NO)

If I enter the root credentials into database.yml then it seems to work but I cannot use root user in production because of internal policies.

The MySQL message has an important pointer:

Access denied for user 'myuser'@'localhost' (using password: NO)

It tells you, that the client doesn't use a password. Apparently, you don't have the password configured correctly in the database.yml for your production db. Once you configure the correct password there, it'll work.

rails by default uses production environment so if you change db to some other environment .

i had the same error this worked

 bundle exec rake db:migrate RAILS_ENV=production

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM