No such file or directory or No such host is known when running migrations
If you are using localhost
as your DATABASE_HOST
in the .env
file, change it to 127.0.0.1
, then run php artisan config:clear
and now try php artisan migrate:install
again.
Can't run migrations in Laravel 8: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
just in .env file change the value of DB_HOST to 127.0.0.1
"change DB_HOST=mysql
to DB_HOST=127.0.0.1
"
SQLSTATE[HY000] [2002] No such file or directory when i try to php artisan migrate
I can see from the screenshot that your phpMyAdmin is connecting to the database at 8889
port, your env
has DB_PORT=3306
, change to DB_PORT=8889
.
Summary of the comment section:
Dan is using MAMP, so the config for mysql connection should contain (for default MAMP settings):
DB_HOST=localhost
DB_PORT=8889
DB_USERNAME=root
DB_PASSWORD=root
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. Error in laravel 8
The error PDO::__construct("mysql:host=mysql;port=3306;dbname=crudtwo", "root", "", [])
shows that you have a wrong entry in .env file
Change the DB_HOST in .env
file as
//Change
DB_HOST=mysql
//To
DB_HOST=127.0.0.1
Php artisan migrate no such file or directory
1) Run command:
composer dump-autoload
2) rollback command:
php artisan migrate:rollback
Then create your migration:
php artisan make:migration create_users_table
DatabaseOperations' object has no attribute 'geo_db_type'. When migrate
The error is showing that there's no database
in Path.
You should reinstall postresql
and remember that select stackbuilder
checbox to tick ok. AND you will automactically redirect to Add Stack builders
to Path.
Laravel Sail - SQLSTATE[HY000] [2002] No such file or directory
Because you are trying to connect to DB container via socket from different container.
There are two separate containers - Laravel and MySQL. Thinks of it like two separate servers.
When you have both unix_socket and db_host in env, you are telling laravel to connect to db at specified host via unix_socket. That is why it didn't work.
When you update the unix_socket env, laravel try to connect to DB via TCP and it work.
P.S: I know this issue is already resolved for you. But in case someone else stumble upon this question, they should have some explanation on why it work and how to fix it in the future.
Related Topics
Relative Path in Require_Once Doesn't Work
When Do I Use Static Variables/Functions in PHP
Codeigniter: Best Way to Structure Partial Views
Laravel No Supported Encrypter Found. the Cipher And/Or Key Length Are Invalid
Symfony2 Routing - Route Subdomains
How to Print SQL Statement in Codeigniter Model
Mysqli_Real_Connect(): (Hy000/2002): No Such File or Directory
Dynamic Paypal Button Generation - Isn't It Very Insecure
Mysql_Escape_String VS MySQL_Real_Escape_String
Using Wget to Run a Cronjob PHP
How to Redirect Back to Form with Input - Laravel 5
Sending Multiple Data Parameters with Jquery Ajax
Detect Exif Orientation and Rotate Image Using Imagemagick
Detect If Android App Has Been Installed on the Device Using a Mobile Web Page - PHP and Js