i have a error when i running php artisan migrate. It shows could not find driver in connection.php and connector.php , any idea to fix it ?error php artisan migrate
Try checking with 127.0.0.1 and check if you have correct db configuration.
Related
I keep this while running php artisan migrate
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
My Environment
Laravel Framework version 5.1.20 (LTS)
Laravel Installer version 1.2.0
PHP 5.6.14 (cli) (built: Oct 2 2015 08:55:56)
mysql Ver 14.14 Distrib 5.6.24, for osx10.10 (x86_64)
.env file
APP_ENV=local
APP_URL=http://localhost/
APP_DEBUG=true
APP_KEY=****
DB_HOST=http://localhost/
DB_DATABASE=name-local
DB_USERNAME=root
DB_PASSWORD=
UNIX_SOCKET = /tmp/mysql.sock
That data-base name-local is exist in my local database.
Any hints / suggestions will be a huge help for me.
Check your DB_HOST on your .env file
DB_HOST=http://localhost/ --> DB_HOST=localhost
Result:
I can migrate peacefully now.
php artisan migrate
Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table
Set DB_HOST=localhost and run the following artisan command
php artisan config:clear it will help you, clear cached config
I finally figured out what was causing this error for me. I'm using docker but I wasn't running php artisan migrate from the shell in the container. I was just running it in Terminal after navigating to the laravel project folder.
Go to your docker dashboard and launch the CLI for the laravel container in the image for your project. Then run the migrate command.
You might also get this error if you are using sail, and you run
php artisan migrate
instead of:
sail artisan migrate
I had the same problem while running Laravel from DDEV.
Solution: run "php artisan migrate" within your DDEV container.
user#ddev-project: ddev ssh
user#ddev-project:/var/www/html$ php artisan migrate
That should solve the issue.
Had the same issue on laravel 8.x after a fresh install. Setting DB_HOST=0.0.0.0 fixed it for me.
Remember to run php artisan config:clear afterwards.
if you are using docker first find your docker container with docker ps command and then execute php artisan migrate command form your container with this command
docker exec -it {containerId}
bash
You can change the SESSION_DRIVER to file. Worked for me.
I'm setting up my project after restoring my macOS Mojave and getting an error. I install MySQL with homebrew.
I tried to change localhost to 127.0.0.1 but it didn't help me
This is my .env
DB_CONNECTION = mysql,
DB_HOST = localhost
DB_PORT = 3306
DB_DATABASE= example
DB_USERNAME=root
DB_PASSWORD=
This is an error message
1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [2002] No
such file or directory")
/Documents/cleaning/example/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31
2 PDOException::("SQLSTATE[HY000] [2002] No such file or
directory")
/Documents/cleaning/example/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
If not exist .env file ,create one from .env-example and in set declare database configs and run command
If you not callin key:generate
php artisan key:generate
If you have been all,exec below command
php artisan config:cache
And try
php artisan migrate
If your still get error try localhost or http://127.0.0.1 ,edit it
And again run below command
php artisan config:cache
Import
-2002 error given error when user and password wrong to host
Try 127.0.0.1 instead of localhost in your .env file.
Run php artisan cache:clear
php artisan migrate --env=production
Above steps works for me.
For example, I have DB_DATABASE=new_db in my .env file and the same as the config/database.php file but still showing error of Unknown database: 'older_database_name'. Please help. Thanks.
Anyway I migrated from MAMP to XAMPP..
restart the server if any changes on .env
try php artisan config:cache and php artisan cache:clear
I am running Laravel 5 with PHP 7.0.6. When I run the php artisan update command, I get the following error:
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
This is obviously database related. This happens on a production machine I have as well as local environment. My site is working in both environments.
Does anyone understand this error? Thanks.
You are missing the PHP-CLI database extension. Your site does work because your server is using the PHP-FPM (where you have the PHP extention of your database installed). But when you run php artisan migrate command you are actually executing it on the PHP-CLI.
This question has already been asked multiple times, however I can't seem to get it to work anyway.
I am trying to migrate a migration I just created with laravel to my freshly created database. However, everytime I type in php artisan migrate I'm getting the above error
PDOException SQLSTATE[HY000] [2002] No such file or directory
What I have done is the following:
Create a database and a database user
CREATE DATABASE openletter CHARACTER SET utf8;
CREATE USER 'openletter'#'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON openletter.* TO 'openletter'#'%';
Add these configs to the .env
DB_HOST=localhost
DB_DATABASE=openletter
DB_USERNAME=openletter
DB_PASSWORD=secret
Creating the migration
php artisan make:migration create_letters_table --create=letters
Migrating the migration
php artisan migrate
Then, the above listed error came.
What I tried
Restart the MySQL Service: vagrant ssh && sudo service mysqld restart
Reloading Homestead/Vagrant: vagrant reload --provision
Setting the database config in config/database.php
Many people telling others to link the mysql socket, but those people are refferencing MAMP or XAMPP or sth. else. I'm however using Homestead
What could also be the problem?
Ok guys, I fixed the issue. I'm an idiot and should be ashamed. The reason it didn't work, was because I wasn't in my vagrant machine.
After doing vagrant ssh navigating to my project cd work/OpenLetter and doing php artisan migrate it worked of course.