-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
- Laravel Version: v8.83.23
- PHP Version: 8.0.12
- Database Driver & Version: mariadb:10.7.1
Description:
Migrations will use PHP to connect to MySQL without problems, but if there are schema SQL files then Laravel will attempt to use the mysql command, which is not available in a docker container (or indeed any server without MySQL where the DB is hosted elsewhere), and so requires the dependency of the MySQL client in order for the migrations to succeed .
This issue has already been discussed here laravel/ideas#2638 where the installation of another dependency (mysql-client) was described as an elegant solution. I'm not sure I agree. If we can use the database connection normally via Laravel, now THAT would be elegant.
Steps To Reproduce:
- Launch a docker compose setup with Laravel in a PHP container and MySQL in its own container
- squash some migrations so you have a database schema sql file
- attempt to migrate
Expected result :
Database seeding completed successfully.
Actual Result
Migration table created successfully.
Loading stored database schema: /var/task/database/schema/your-schema.dump
Symfony\Component\Process\Exception\ProcessFailedException
The command "mysql --user="${:LARAVEL_LOAD_USER}" --*** --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --database="${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"" failed.
Exit Code: 127(Command not found)
Working directory: /var/www/html
Output:
================
Error Output:
================
sh: mysql: not found
at /var/task/vendor/symfony/process/Process.php:272
268▕ */
269▕ public function mustRun(callable $callback = null, array $env = []): self
270▕ {
271▕ if (0 !== $this->run($callback, $env)) {
➜ 272▕ throw new ProcessFailedException($this);
273▕ }
274▕
275▕ return $this;
276▕ }
+22 vendor frames
23 /var/task/artisan:43
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Logs: You may review its logs using the `hook:log 2145551` command.
Error: Process completed with exit code 1.
Temporary Fix
- In the Dockerfile of the PHP container, install another mysql
(RUN apt-get -y --no-install-recommends install default-mysql-server)
Metadata
Metadata
Assignees
Labels
No labels