[英]Docker PHP MYSQL Laravel 7 php artisan migrate (could not find driver)
找不到驱动程序(SQL:select * 来自 information_schema.tables,其中 table_schema = db_name 和 table_name = migrations 和 table_type ='BASE TABLE')
在供应商/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674|}
675|
+36 vendor frames
37 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
码头作曲家
version: "3.4"
services:
mysql:
image: mysql
ports:
- 3306:3306
volumes:
- /home/docker_lib/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M;
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8008:80
environment:
- PMA_ARBITRARY=1
restart: always
nginx:
image: nginx:alpine
ports:
- 80:80
volumes:
- /home/docker_html:/usr/share/nginx/html
php:
image: devilbox/php-fpm:7.4-work
volumes:
- /home/docker_html:/var/www/html
php7.4(php.ini配置文件)
extension=pdo_mysql.so
.env 文件
DB_CONNECTION=mysql
DB_HOST=db_ip
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=root
DB_PASSWORD=123456
你可以 go 手册,除非你在 CICD 管道上。
试试这个: 1-在 DB_HOST 上设置 Mysql docker 容器的名称。 不要忘记保存文件更改:) 2-./vendor/bin/sail artisan migrate 3-./vendor/bin/sail artisan db:seed
4(可选)- 2 和 3 可以使用(全新删除所有表并重新运行迁移)一起执行 php artisan migrate:fresh --seed
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.