mysql - Laravel 6.0 迁移 - SQLSTATE[HY000] [2002] 没有这样的文件或目录

标签 mysql macos xampp mariadb laravel-6

我正在尝试使用 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

最佳答案

最后我找到了解决方案,macOS 中最新版本的 xampp 可与虚拟机配合使用,因此当我运行迁移时,它会在我的计算机上而不是在本地计算机上获取数据库。 下载最新版本无需虚拟机就可以了!

关于mysql - Laravel 6.0 迁移 - SQLSTATE[HY000] [2002] 没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58066886/

相关文章:

php - 如何在不影响生产性能的情况下向 18 GB innodb mysql 表添加索引?

php - 将表结果连接到各个列

macos - 以编程方式从 1024 * 1024 大小的 NSImage 创建图标 (ICNS)

mysql - 如何解决安装 xampp 服务器时出现 api-ms-win-crt-runtime-|l1-1-0.dll 错误

linux - 无法将文件传输到 cgi-bin 文件夹

javascript - FullCalendar 事件定向到错误的 url

objective-c - 如何在基于文档的应用程序的文档窗口 Controller 中接收菜单项事件?

linux - 下载多个文件,具有不同的最终名称

PHP exec 命令运行 python 脚本但不运行 python3

php - 可以从多个表单将多个数据插入到单个表中吗?