#始めに
「はじめてのLaravel6入門 AWS Cloud9で学ぶ」という本で勉強しています。
#開発環境
PHP Version7.2
laravel Verson6.18.3
#$ php artisan migrateが実行できない
Illuminate\Database\QueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = c9 and table_name = migrations and table_type = 'BASE TABLE')
at /home/ec2-user/environment/cms/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
Exception trace:
1 PDOException::("could not find driver")
/home/ec2-user/environment/cms/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
2 PDO::__construct("mysql:host=localhost;port=3306;dbname=c9", "root", "root", [])
/home/ec2-user/environment/cms/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Please use the argument -v to see more details.
上記のエラー文が出てきて実行できない。
$ php -m | grep pdo
pdo_sqlite
"could not find driver"というエラー文を参考に、MySQLをインストールしようと試みるもうまくいかず。
#解決方法
sudo yum -y install php72 php72-cli php72-common php72-devel php72-mysqlnd php72-pdo php72-xml php72-gd php72-intl php72-mbstring php72-mcrypt php72-opcache php72-pecl-apcu php72-pecl-imagick php72-pecl-memcached php72-pecl-redis php72-pecl-xdebug
上記のPHPのバージョンを7.2に更新するコマンドで解決できた。