Why does not want to connect to a MySQL database?

Please help with connection problem. A VPS, it deployed MySQL database, created a user userdevel with password 0000 and full rights on the database dbdevel. When connecting to the database through a console connection is successful:
mysql-u userdevel -p

On the server you deployed the bundle of Apache + Passenger, created the website in development mode debug for instant debugging deployed applications:
# /etc/apache2/sites-available/develop-website.conf
<virtualhost *:80> 
...
 PassengerAppEnv development 
...
</virtualhost>

In the folder you copied the Ruby on Rails project in config/database.yml specified logins passwords to connect to:
default: &default
 adapter: mysql2
 pool: 5
 timeout: 5000
 host: 127.0.0.1
 password: 0000
 encoding: utf8

development:
 <<: *default
 database: userdevel
 username: dbdevel
(just say: replace 127.0.0.1 by localhost in the host line did not help)

But when you try to open website Action Controller writes an error:
Access denied for user 'userdevel'@'localhost' (using password: YES)

Again, using the console to mysql this user (a login and password) connects without problems.

Here is a table of users from the DB:
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| userdevel | % |
| debian-sys-maint | localhost |
| mysql.sys | localhost |
| root | localhost |
| userdevel | localhost |
| usertest | localhost |
| userwork | localhost |
+------------------+-----------+
7 rows in set (0.00 sec)

What did I do wrong? Tell me, please.
August 23rd 19 at 10:53
2 answers
August 23rd 19 at 10:55
Solution
and for the "userdevel" right all this ?
Yes, the right the a team (performed the command after creating user and DB):
user@ovz1:~$ mysql-u root-p
mysql > GRANT ALL PRIVILEGES ON dbdevel.* TO userdevel@localhost;
- Dennis14 commented on August 23rd 19 at 10:58
: to mind then or what not comes , try those as root without a password if you pass then your password is not correct - virgie_Wehner22 commented on August 23rd 19 at 11:01
: Sorry, does not pass. Went to read about stealth network communications in the linux servers. Maybe it's the VPS and configure network interfaces. - Dennis14 commented on August 23rd 19 at 11:04
: the problem was in access rights, You are right: in the SQL string selection right I forgot to add WITH GRANT OPTION:

It was (incorrectly):
mysql > GRANT ALL PRIVILEGES ON dbdevel.* TO userdevel@localhost;


Must be (correctly):
mysql > GRANT ALL PRIVILEGES ON dbdevel.* TO userdevel@localhost WITH GRANT OPTION;

He performed his second string for the user and all rustled as it is necessary. Thank you for your help! - Dennis14 commented on August 23rd 19 at 11:07
August 23rd 19 at 10:57
Our database user@remote.domain.com and user@127.0.0.1 is different polzoatel. You clearly stated that
"Access denied for user 'userdevel'@'localhost' (using password: YES)"

That is, either no such user or password is different. Check the list of users and add rights to the appropriate user.
In any case, created user userdevel@127.0.0.1 and gave him full rights on the database dbdevel:
mysql> grant all privileges on dbdevel.* to userdevel@127.0.0.1 identified by '0000';
Query OK, 0 rows affected, 1 warning (0.05 sec)

mysql> select user,host from mysql.user; 
+------------------+-----------+ 
| user | host | 
+------------------+-----------+ 
| userdevel | % | 
| userdevel | 127.0.0.1 | 
| debian-sys-maint | localhost | 
| mysql.sys | localhost | 
| root | localhost | 
| userdevel | localhost | 
| usertest | localhost | 
| userwork | localhost | 
+------------------+-----------+ 
8 rows in set (0.00 sec)

The error remains the same:
Access denied for user 'userdevel'@'localhost' (using password: YES)

80125b71cf7245629205fdf27372ccad.jpg
What is most interesting, despite the settings the config file/database.yml in the error window, everything is also written localhost and not 127.0.0.1. - Dennis14 commented on August 23rd 19 at 11:00
userdevel@127.0.0.1 and userdevel@localhost is a DIFFERENT user. - virgie_Wehner22 commented on August 23rd 19 at 11:03
: I understand You. And later wrote: in the database add both user userdevel@127.0.0.1 and userdevel@localhost. But no matter what is written in config/database.yml or host: 127.0.0.1 or host: localhost connection fails. - Dennis14 commented on August 23rd 19 at 11:06
: in the example above, the grant was only userdevel@127.0.0.1
if the license is issued all, then my ideas run out ;( - Dennis14 commented on August 23rd 19 at 11:09
: Yes, like all.
mysql> show grants for 'userdevel'@'localhost';
+------------------------------------------------------------------------+
| Userdevel Grants for@localhost |
+------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'userdevel'@'localhost' |
| GRANT ALL PRIVILEGES ON `dbdevel`.* TO 'userdevel'@'localhost' |
+------------------------------------------------------------------------+
2 rows in set (0.04 sec)

mysql> show grants for 'userdevel'@'127.0.0.1';
+------------------------------------------------------------------------+
| Grants for userdevel@127.0.0.1 |
+------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'userdevel'@'127.0.0.1' |
| GRANT ALL PRIVILEGES ON `dbdevel`.* TO 'userdevel'@'127.0.0.1' |
+------------------------------------------------------------------------+
2 rows in set (0.00 sec)

In any case, thanks for the help. - Dennis14 commented on August 23rd 19 at 11:12
: Turned incorrectly allocated rights to the SQL string assignment of the rights is not enough WITH GRANT OPTION on the end. Thank you for your help! - misty_Koepp commented on August 23rd 19 at 11:15

Find more questions by tags MySQLPassengerRubyRuby on Rails