【问题标题】:Laravel 8 Migrate Error Using XAMPP Database on MAC在 MAC 上使用 XAMPP 数据库的 Laravel 8 迁移错误
【发布时间】:2021-04-08 21:41:42
【问题描述】:

我在 MAC 上使用 Laravel Framework 8.20.1 & XAMPP For MySQL Database,当我运行这个命令时: php artisan migrate 它显示一条错误消息,不知道为什么?

.env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=atamana_db
DB_USERNAME=root
DB_PASSWORD=

错误:

Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = atamana_db and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕ 

      +33 vendor frames 
  34  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

【问题讨论】:

标签: php mysql laravel xampp


【解决方案1】:

我强烈建议使用 Homebrew 来设置 MySQL。

访问https://brew.sh/

打开终端并在 brew 网站上运行命令进行安装。

然后使用安装mysql

brew install mysql

通过运行启动 MySQL

brew services start mysql

通过运行创建数据库

mysql -u root -p
CREATE DATABASE atamana_db;

由于 PHP 还不了解caching_sha2_password,请尝试使用 mysql_native_password 使用此命令:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

然后按 Control + C 退出 MySQL

再次尝试运行迁移。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-01
    • 2015-03-02
    • 2020-08-16
    • 2019-04-25
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    • 2018-12-06
    相关资源
    最近更新 更多