300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > xampp mysql 内存溢出_php - SQLSTATE [HY000] [2002]连接被拒绝 - 堆栈内存溢出

xampp mysql 内存溢出_php - SQLSTATE [HY000] [2002]连接被拒绝 - 堆栈内存溢出

时间:2024-02-09 12:19:05

相关推荐

xampp mysql 内存溢出_php - SQLSTATE [HY000] [2002]连接被拒绝 - 堆栈内存溢出

我通过将主机更改为localhost尝试了其他解决方案,但仍然没有帮助。

我正在尝试使用php artisan migrate连接MySQL,但出现以下异常:

: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = sample_db and table_name = migrations and table_type = 'BASE TABLE')

at /Users/php_api/sample_api/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664

Exception trace:

1 PDOException::("SQLSTATE[HY000] [2002] Connection refused")

/Users/php_api/sample_api/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=sample_db", "root", "", [])

/Users/php_api/sample_api/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

我通过netstat -tln检查了端口3306, netstat -tln在其中找到,这是我发现的记录:

tcp4 0 0 127.0.0.1.5037 127.0.0.1.62255 ESTABLISHED

tcp4 0 0 127.0.0.1.62255 127.0.0.1.5037 ESTABLISHED

这是我的.env文件:

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=sample_db

DB_USERNAME=root

DB_PASSWORD=

这是我的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', 'sample_db'),

'username' => env('DB_USERNAME', 'root'),

'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'),

]) : [],

],

我不知道我在这里做什么错。

编辑

如果我尝试更改以下属性,则会遇到另一个问题:

DB_HOST=localhost

DB_PORT=8080

这是我得到的问题:

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。