1

Google many web pages rarely encounter this problem in docker environment,Run docker-composer and create laravel7 in the Linux system, and run the php artisan migrate command to report an error:

could not find driver (SQL: select * from information_schema.tables where table_schema = db_name and table_name = migrations and table_type ='BASE TABLE')

at vendor/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()

docker-composer

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 configuration file )

extension=pdo_mysql.so

.env file

DB_CONNECTION=mysql
DB_HOST=db_ip
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=root
DB_PASSWORD=123456

jo.ma
  • 17
  • 1
  • 6

1 Answers1

0

you can go manual unless you are on a CICD pipeline.

Try this: 1-on the DB_HOST set the name of the Mysql docker container. DONT forget to save the file change :) 2-./vendor/bin/sail artisan migrate 3-./vendor/bin/sail artisan db:seed

4(optional)- 2 and 3 can be executed together using (fresh drop all tables and reruns migrations) php artisan migrate:fresh --seed

jmvcollaborator
  • 2,141
  • 1
  • 6
  • 17