0

i'm building a sandbox for Laravel with mysql to try out the framework! I'm running in fedora 28. I've already migrated my tables using php artisan, but when I try table get the values using$blog = DB::table('blogs')->get(); the error appears.

Here's my .env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:oAfajCF2UaMlnx1WC1iKZ1eb0n8QtGWZm8OHEqcJu8k=
APP_DEBUG=true
APP_URL=http://localhost:8000

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=sandbox
DB_USERNAME=root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"´

What might be the problem? Thanks in advance, and sorry if i missed some code or config, i'm newbie in backend!

  • Have you installed and configured the MySQL for the version of PHP configured to work with your web server? This is likely a different version of PHP to what's running on the CLI. – fubar Oct 15 '18 at 01:43
  • `php -i|grep mysql` Do you have mysql in your php info? – Gavin Kwok Oct 15 '18 at 01:44
  • @fubar how can i tell if mysql and PHP are configured to my web server? – Pedro Fernandes Martins Oct 15 '18 at 01:50
  • @GavinKwok I do have mysql in my php info – Pedro Fernandes Martins Oct 15 '18 at 01:52
  • @PedroFernandesMartins, you can either re-run the command @GavinKwok posted, but against the PHP binary configured with your webserver, or you could add `phpinfo();` to an empty controller action and check the result. – fubar Oct 15 '18 at 01:56
  • Have you tried [this](https://stackoverflow.com/questions/35240414/laravel-5-pdoexception-could-not-find-driver/35240511)? – Gavin Kwok Oct 15 '18 at 01:56
  • @fubar I used phpinfo(); in the index of my sandbox project. the mysql extensions, and pdo extension all appear in the page! Does this mean they're correctly configured? – Pedro Fernandes Martins Oct 15 '18 at 02:05
  • @GavinKwok yes, i tried and it returned this warning after php artisan serve command [Sun Oct 14 23:04:39 2018] PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib64/php/modules/pdo_mysql.so (/usr/lib64/php/modules/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /usr/lib64/php/modules/pdo_mysql.so.so (/usr/lib64/php/modules/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 – Pedro Fernandes Martins Oct 15 '18 at 02:07
  • @Pedro Fernandes Martins `Unable to load dynamic library 'pdo_mysql.so' ` You should probably reinstall your php, make sure you have this line when you configure the source `--with-pdo-mysql` – Gavin Kwok Oct 15 '18 at 02:10
  • @GavinKwok did that as my last resource and I still getting the warning, but it's working now! Should I be worried? – Pedro Fernandes Martins Oct 15 '18 at 02:13
  • do this: restart your webserver and php-fpm. if the error still appears, check: which php does laravel use. does it have pdo-mysql extension(check `php -m`). – Gavin Kwok Oct 15 '18 at 02:37
  • @GavinKwok I realized after all my pdo_msql was for a different version of mysql indeed! Thanks a lot!! – Pedro Fernandes Martins Oct 17 '18 at 13:27

0 Answers0