Reputation: 21
I'm trying to create the migrations with laravel and i get this error:
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = tutories and table_name = migrations and table_type = 'BASE TABLE')
at /Users/ivanortega/.bitnami/stackman/machines/xampp/volumes/root/htdocs/codi/UVIC/Tutories/vendor/laravel/framework/src/Illuminate/Database/Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {
> 665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|
Exception trace:
1 PDOException::("SQLSTATE[HY000] [2002] No such file or directory")
/Users/ivanortega/.bitnami/stackman/machines/xampp/volumes/root/htdocs/codi/UVIC/Tutories/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
2 PDO::__construct("mysql:unix_socket=/var/mysql/mysql.sock;dbname=tutories", "root", "", [])
/Users/ivanortega/.bitnami/stackman/machines/xampp/volumes/root/htdocs/codi/UVIC/Tutories/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
I have tried to change the hostname, and the socket. Nothing works
This is my .env conf file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tutories
DB_USERNAME=root
DB_PASSWORD=
DB_SOCKET=/var/mysql/mysql.sock
I check that the socket exists, and I also create a link to /tmp/mysql.sock. I change the php.ini file:
pdo_mysql.default_socket=/var/mysql/mysql.sock
Program versions:
XAMPP: 7.3.9
PHP: 7.3.6
MariaDB: 10.0.34
MAC:MacOS Mojave v10.14.6
Upvotes: 0
Views: 1646
Reputation: 1213
FOR Mac OS, try to add the following line in your .env
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
Upvotes: 0
Reputation: 598
here i have two solution
change in you .env file
DB_HOST=127.0.0.1
to
DB_HOST=localhost
and then run following command to clear config file php artisan config:clear
second way to solved this issue is add following line in you .env file
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
Upvotes: 1
Reputation: 21
Finally I fonund the solution, newest versions of xampp in macOS works with a virtual machine, so when I run the migrate it was taking the db on my computer, not in the local machine. Downloading the last version without the virtual machine works!
Upvotes: 2