mercredi 2 octobre 2019

Laravel host is not allowed to connect to this mysql server (Centos 7)

I have a fresh installation of mysql-community-server 5.7 installed on centos 7. I can successfully connect to the mysql server remotely, also locally using mysql command. But when trying to connect with laravel (latest version of 5.8.*), I get the error Host 'SERVER_IP_ADDRESS' is not allowed to connect to this MySQL server.

(There are great posts about this like in here and here, but it's not the case and the problem doesn't seem to go away.)

So this made me think maybe this isn't a mysql problem.

Here is mysql conf from /etc/my.cnf:

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

I'm running PHP-FPM and nginx as a reverse proxy, everything works fine, until laravel tries to connect to the db.

I also tried changing the DB_HOST from 127.0.0.1 to localhost , server_ip_address, domain_name,... even in the .env file. changed the DB_USERNAME and DB_PASSWORD to sth random to see if I get a different error, stuck with the same one.

MySQL user table:

+---------------+-----------+
| user          | host      |
+---------------+-----------+
| deka          | %         |
| root          | %         |
| deka          | localhost |
| mysql.session | localhost |
| mysql.sys     | localhost |
| root          | localhost |
+---------------+-----------+

(Deleted every user record with hostname '%' or '_' as other posts instructed and recreated the users with full permission on the database. even when there was no user with wild cards, it didn't work.)

root user grants:

+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+

deka user grants:

+----------------------------------------------------------------------+
| Grants for deka@%                                                    |
+----------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'deka'@'%'                                     |
| GRANT ALL PRIVILEGES ON `dekatech`.* TO 'deka'@'%' WITH GRANT OPTION |
+----------------------------------------------------------------------+

I also:

  1. Made sure laravel is not caching any config.
  2. Flushed privileges on every change.

None of the users seem to work.

Also mysql log files look pretty standard, except the two last lines.

2019-10-02T20:54:53.246940Z 0 [Warning] CA certificate ca.pem is self signed.
2019-10-02T20:54:53.249171Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-10-02T20:54:53.249220Z 0 [Note] IPv6 is available.
2019-10-02T20:54:53.249235Z 0 [Note]   - '::' resolves to '::';
2019-10-02T20:54:53.249263Z 0 [Note] Server socket created on IP: '::'.
2019-10-02T20:54:53.289907Z 0 [Note] Event Scheduler: Loaded 0 events
2019-10-02T20:54:53.290223Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.27-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2019-10-02T20:56:09.047393Z 2 [Warning] IP address 'SERVER_IP_ADDRESS' could not be resolved: Name or service not known
2019-10-02T20:56:19.052216Z 2 [Note] Got timeout reading communication packets


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire