access denied for 'user'@'xx.xx.xxx.xxx" when run .net core web in linux server with mysql connect

Solution 1:

In MySQL, a user is identified by both user and host.

This user:

 admin@localhost

is not the same user as

 admin@'10.242.167.235'

As one option, you could do this to allow connection:

  GRANT USAGE ON *.* TO admin@'10.242.167.235' IDENTIFIED BY 'mysecret' ;
  GRANT ALL ON confWeb.* TO admin@'10.242.167.235' ;

For a longer discussion of the MySQL Access Privilege System, including "wildcards", the special meaning of localhost, using IP addresses instead of hostnames, etc.

http://dev.mysql.com/doc/refman/5.7/en/privilege-system.html

Solution 2:

I do not really know why, but appareantly, it worked when I used the with grant option and first gave access to the database, and then to its tables. Here is the list of commands that I entered :

mysql> create user 'admin'@'localhost' identified by 'admin';
mysql> grant all privileges on confWeb to 'admin'@'10.69.101.%' identified by 'admin' with grant option;
mysql> grant all privileges on confWeb.* to 'admin'@'10.69.101.%' identified by 'admin' with grant option;
mysql> flush privileges;

Again, I don't really know why it didn't work before and the answers that I saw look like all the documentation I have seen but it looks my problem was somewhere else.