emad-zaamout / Laravel-Complete-Dockerization

https://ahtcloud.com
70 stars 85 forks source link

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for database failed: Temporary failure in name resolution (SQL: select * from information_schema.tables where table_schema = chatapp and table_name = migrations and table_type = 'BASE TABLE') #2

Open karlog100 opened 1 year ago

karlog100 commented 1 year ago

Hello

I have an issue where queue exits with code 0 after php gives the following:

Attaching to laraveldoubtdk-database-1, laraveldoubtdk-node-1, laraveldoubtdk-php-1, laraveldoubtdk-queue-1, laraveldoubtdk-redis-1, laraveldoubtdk-websocket-1 laraveldoubtdk-redis-1 | 1:C 25 Apr 2023 20:53:16.659 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo laraveldoubtdk-redis-1 | 1:C 25 Apr 2023 20:53:16.660 # Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started laraveldoubtdk-redis-1 | 1:C 25 Apr 2023 20:53:16.660 # Configuration loaded laraveldoubtdk-redis-1 | 1:M 25 Apr 2023 20:53:16.664 monotonic clock: POSIX clock_gettime laraveldoubtdk-redis-1 | 1:M 25 Apr 2023 20:53:16.667 Running mode=standalone, port=6379. laraveldoubtdk-redis-1 | 1:M 25 Apr 2023 20:53:16.667 # Server initialized laraveldoubtdk-redis-1 | 1:M 25 Apr 2023 20:53:16.667 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause fail ures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. laraveldoubtdk-redis-1 | 1:M 25 Apr 2023 20:53:16.683 Creating AOF base file appendonly.aof.1.base.rdb on server start laraveldoubtdk-redis-1 | 1:M 25 Apr 2023 20:53:16.715 Creating AOF incr file appendonly.aof.1.incr.aof on server start laraveldoubtdk-redis-1 | 1:M 25 Apr 2023 20:53:16.715 * Ready to accept connections laraveldoubtdk-database-1 | 2023-04-25 20:53:16+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.31-1.el8 started. laraveldoubtdk-websocket-1 | Env file already exists laraveldoubtdk-websocket-1 | Running websocket container laraveldoubtdk-node-1 | Welcome to Node.js v14.21.3. laraveldoubtdk-node-1 | Type ".help" for more information. laraveldoubtdk-websocket-1 | Starting the WebSocket server on port 6001... laraveldoubtdk-database-1 | 2023-04-25 20:53:17+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' laraveldoubtdk-database-1 | 2023-04-25 20:53:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.31-1.el8 started. laraveldoubtdk-database-1 | 2023-04-25 20:53:17+00:00 [Note] [Entrypoint]: Initializing database files laraveldoubtdk-database-1 | 2023-04-25T20:53:17.218612Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
laraveldoubtdk-database-1 | 2023-04-25T20:53:17.218678Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.31) initializing of server in progress as process 79 laraveldoubtdk-database-1 | 2023-04-25T20:53:17.223900Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. laraveldoubtdk-queue-1 | Env file already exists laraveldoubtdk-queue-1 | Running queue container laraveldoubtdk-php-1 | Env file already exists laraveldoubtdk-php-1 | Running app container laraveldoubtdk-database-1 | 2023-04-25T20:53:17.548774Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. laraveldoubtdk-database-1 | 2023-04-25T20:53:18.898953Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. laraveldoubtdk-database-1 | 2023-04-25 20:53:22+00:00 [Note] [Entrypoint]: Database files initialized laraveldoubtdk-database-1 | 2023-04-25 20:53:22+00:00 [Note] [Entrypoint]: Starting temporary server laraveldoubtdk-database-1 | 2023-04-25T20:53:23.090306Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. laraveldoubtdk-database-1 | 2023-04-25T20:53:23.091495Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 130 laraveldoubtdk-database-1 | 2023-04-25T20:53:23.100425Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. laraveldoubtdk-database-1 | 2023-04-25T20:53:23.182868Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. laraveldoubtdk-database-1 | 2023-04-25T20:53:23.399623Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. laraveldoubtdk-database-1 | 2023-04-25T20:53:23.399659Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. laraveldoubtdk-database-1 | 2023-04-25T20:53:23.401643Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. laraveldoubtdk-database-1 | 2023-04-25T20:53:23.413869Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock laraveldoubtdk-database-1 | 2023-04-25T20:53:23.414055Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.31' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL. laraveldoubtdk-database-1 | 2023-04-25 20:53:23+00:00 [Note] [Entrypoint]: Temporary server started. laraveldoubtdk-database-1 | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock' laraveldoubtdk-database-1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. laraveldoubtdk-database-1 | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it. laraveldoubtdk-database-1 | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it. laraveldoubtdk-database-1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. laraveldoubtdk-database-1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. laraveldoubtdk-database-1 | 2023-04-25 20:53:25+00:00 [Note] [Entrypoint]: Creating database chatapp laraveldoubtdk-database-1 | 2023-04-25 20:53:25+00:00 [Note] [Entrypoint]: Creating user karlog laraveldoubtdk-database-1 | 2023-04-25 20:53:25+00:00 [Note] [Entrypoint]: Giving user karlog access to schema chatapp laraveldoubtdk-database-1 | laraveldoubtdk-database-1 | 2023-04-25 20:53:25+00:00 [Note] [Entrypoint]: Stopping temporary server laraveldoubtdk-database-1 | 2023-04-25T20:53:25.443032Z 13 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.31). laraveldoubtdk-database-1 | 2023-04-25T20:53:27.620685Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.31) MySQL Community Server - GPL. laraveldoubtdk-database-1 | 2023-04-25 20:53:28+00:00 [Note] [Entrypoint]: Temporary server stopped laraveldoubtdk-database-1 | laraveldoubtdk-database-1 | 2023-04-25 20:53:28+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up. laraveldoubtdk-database-1 | laraveldoubtdk-database-1 | 2023-04-25T20:53:28.698793Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead. laraveldoubtdk-database-1 | 2023-04-25T20:53:28.700663Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.31) starting as process 1 laraveldoubtdk-database-1 | 2023-04-25T20:53:28.710018Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. laraveldoubtdk-database-1 | 2023-04-25T20:53:28.841312Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. laraveldoubtdk-database-1 | 2023-04-25T20:53:29.016206Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. laraveldoubtdk-database-1 | 2023-04-25T20:53:29.016241Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. laraveldoubtdk-database-1 | 2023-04-25T20:53:29.018246Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a differenlaraveldoubtdk-php-1 | ➜ 742▕ throw new QueryException( laraveldoubtdk-php-1 | 743▕ $query, $this->prepareBindings($bindings), $e laraveldoubtdk-php-1 | 744▕ ); laraveldoubtdk-php-1 | 745▕ } laraveldoubtdk-php-1 | 746▕ } laraveldoubtdk-php-1 | laraveldoubtdk-php-1 | +36 vendor frames laraveldoubtdk-php-1 | 37 artisan:37 laraveldoubtdk-php-1 | Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) laraveldoubtdk-php-1 | Application key set successfully. laraveldoubtdk-php-1 | Application cache cleared successfully. laraveldoubtdk-php-1 | Configuration cache cleared successfully. laraveldoubtdk-php-1 | Route cache cleared successfully. laraveldoubtdk-php-1 | Route cache cleared successfully. laraveldoubtdk-php-1 | Starting Laravel development server: http://0.0.0.0:8000 laraveldoubtdk-php-1 | [Tue Apr 25 20:53:58 2023] PHP 8.1.18 Development Server (http://0.0.0.0:8000) started laraveldoubtdk-queue-1 exited with code 0

image

image

mickythompson commented 1 year ago

I ran into a similar issue. The error I was getting was: _could not find driver (SQL: select * from information_schema.tables where table_schema = chatapp and table_name = migrations and tabletype = 'BASE TABLE')

When I looked at the php.ini files, I realized there were 2: php.ini-development php.ini-production

I updated APP_ENV in .env from =local to =development, helping get me past my error. I'll let you know if I find anything related to your error, but I wanted to share what I know.

fatihalp commented 1 year ago

use:

DB_CONNECTION=mysql
DB_HOST=host.docker.internal
junaidiar19 commented 3 months ago

use:

DB_CONNECTION=mysql
DB_HOST=host.docker.internal

Finally, it's worked for me!