mariadb Laravel 6.0迁移- SQLSTATE[HY 000] [2002]没有此类文件或目录

vnzz0bqm  于 2022-11-08  发布在  其他
关注(0)|答案(3)|浏览(132)

我尝试用laravel创建迁移,我得到这个错误:

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

我尝试过更改主机名和套接字,但没有任何效果
这是我的.env conf文件:

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

我检查套接字是否存在,并创建一个指向/tmp/mysql. sock的链接。我更改php.ini文件:

pdo_mysql.default_socket=/var/mysql/mysql.sock

程序版本:

XAMPP: 7.3.9
PHP: 7.3.6
MariaDB: 10.0.34
MAC:MacOS Mojave v10.14.6
avkwfej4

avkwfej41#

最后,我找到了解决方案,最新版本的xampp在macOS中使用虚拟机,所以当我运行migrate时,它是在我的电脑上,而不是在本地机器上的数据库。

nwnhqdif

nwnhqdif2#

这里我有两个解决方案
1..env文件中更改

一月一日

一个月一个月

然后运行以下命令清除配置文件php artisan config:clear
1.解决这个问题第二种方法是在.env文件中添加以下行

DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

i2byvkas

i2byvkas3#

对于Mac OS,请尝试在.env中添加以下行

DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

相关问题