简体   繁体   中英

Laravel driver not found, database misconnection?

I'm getting this error:

PDOException in Connector.php line 55: could not find driver
in Connector.php line 55
at PDO->__construct('mysql:host=localhost:8080;dbname=db', 'root', '', array('0', '2', '0', false, false)) in Connector.php line 55

On my .env file I have the credentials as

DB_HOST=localhost:8080
DB_DATABASE=db
DB_USERNAME=root
DB_PASSWORD=

My wamp is set to port 8080, and when my laravel is viewing on port 8000 via artisan serve. Is there a disconnect with this? All of the pdo modules are in the php.ini

I don't believe that you can use artisan serve with WAMP, as they are actually two different servers (artisan serve utilizes PHPs built in web server which has no relation to WAMP).

You should checkout this post to get an idea of how to setup Laravel to work with WAMP properly.

You didn't show your list of extensions.

WAMPP

  • Check if you have a file php-cli.ini
  • Check or add the following lines to php-cli.ini :
    • extension=php_pdo_mysql.dll
    • extension=php_mbstring.dll
  • Doesn't php-cli.ini exists? Check or add the lines to your php.ini
  • Restart WAMPP

Homestead

I strongly recommend Homestead as your local development server.

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!

Homestead runs on any Windows, Mac, or Linux system, and includes the Nginx web server, PHP 7.0, MySQL, Postgres, Redis, Memcached, Node, and all of the other goodies you need to develop amazing Laravel applications ( https://laravel.com/docs/master/homestead )

you are serving from two totally different environments, your wamp is probably using a different php version that your artisan. check where both of those php configs are located and install whatever drivers that are missing keep in mind php7 is missing a few pdo drivers if not all.

Remove port number 8080 from .env file as follows

DB_HOST=localhost
DB_DATABASE=db
DB_USERNAME=root
DB_PASSWORD=

Now try that by placing above values.

Don't forgot to restart your server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM