mysql 运行“php artisan migrate”时出现错误SQLSTATE[HY000] [2054]

rt4zxlrg  于 2023-03-22  发布在  Mysql
关注(0)|答案(1)|浏览(142)

有人有解决方案吗?我已经被困了4天,寻找解决方案,以解决运行php artisan migrate时错误SQLSTATE[HY 000] [2054]。我的MySQL版本是8.0.32,适用于arm 64上的macos11.7(Homebrew)。PHP版本是7.3.24我在M1 Macbook上使用macOS Big Sur 11.3。
从.env文件:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laragigs
DB_USERNAME=david
DB_PASSWORD=password

在config/database.php文件中:

'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],`

我已交叉检查凭据和数据库名称是否与.env文件中的相同。我还尝试了echo 'export PATH="/usr/local/mysql/bin:$PATH”'〉〉~/.bash_profile

kupeojn6

kupeojn61#

解决了!我有一个错字时做:ALTER USER 'username here'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password here';

相关问题