Laravel 8 在 MAC 上使用 XAMPP 数据库迁移错误
Laravel 8 Migrate Error Using XAMPP Database on MAC
我在 MAC 上使用 Laravel Framework 8.20.1 和 XAMPP For MySQL 数据库,当我 运行 这个命令: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))
我强烈建议使用 Homebrew 来设置 MySQL。
打开终端,运行brew 网站上的命令进行安装。
然后使用
安装mysql
brew install mysql
开始 MySQL 运行宁
brew services start mysql
通过 运行ning
创建您的数据库
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
再次尝试 运行迁移。
我在 MAC 上使用 Laravel Framework 8.20.1 和 XAMPP For MySQL 数据库,当我 运行 这个命令: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))
我强烈建议使用 Homebrew 来设置 MySQL。
打开终端,运行brew 网站上的命令进行安装。
然后使用
安装mysqlbrew install mysql
开始 MySQL 运行宁
brew services start mysql
通过 运行ning
创建您的数据库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
再次尝试 运行迁移。