运行时出错:
PHP工匠迁移:重置
在my Laravel网站的根目录中:
1 PDOException::("SQLSTATE[HY000] [2002] No connection could be made because
the target machine actively refused it.
")
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connectors\Connector.php : 68
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=homestead", "homes
tead", "secret", [])
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connectors\Connector.php : 68
Please use the argument -v to see more details.
当我运行-v时,我得到了以下信息:
1 PDOException::("SQLSTATE[HY000] [2002] No connection could be made because
the target machine actively refused it.
")
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connectors\Connector.php : 68
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=homestead", "homes
tead", "secret", [])
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connectors\Connector.php : 68
3 Illuminate\Database\Connectors\Connector::createPdoConnection("mysql:host=
127.0.0.1;port=3306;dbname=homestead", "homestead", "secret", [])
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connectors\Connector.php : 44
4 Illuminate\Database\Connectors\Connector::createConnection("mysql:host=127
.0.0.1;port=3306;dbname=homestead", [])
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connectors\MySqlConnector.php : 24
5 Illuminate\Database\Connectors\MySqlConnector::connect()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connectors\ConnectionFactory.php : 183
6 Illuminate\Database\Connectors\ConnectionFactory::Illuminate\Database\Conn
ectors\{closure}()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 915
7 call_user_func(Object(Closure))
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 915
8 Illuminate\Database\Connection::getPdo()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 940
9 Illuminate\Database\Connection::getReadPdo()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 399
10 Illuminate\Database\Connection::getPdoForSelect()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 325
11 Illuminate\Database\Connection::Illuminate\Database\{closure}("select * fr
om information_schema.tables where table_schema = ? and table_name = ?")
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 657
12 Illuminate\Database\Connection::runQueryCallback("select * from informatio
n_schema.tables where table_schema = ? and table_name = ?", Object(Closure))
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 624
13 Illuminate\Database\Connection::run("select * from information_schema.tabl
es where table_schema = ? and table_name = ?", Object(Closure))
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Connection.php : 333
14 Illuminate\Database\Connection::select("select * from information_schema.t
ables where table_schema = ? and table_name = ?")
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Schema\MySqlBuilder.php : 18
15 Illuminate\Database\Schema\MySqlBuilder::hasTable("migrations")
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Migrations\DatabaseMigrationRepository.php : 169
16 Illuminate\Database\Migrations\DatabaseMigrationRepository::repositoryExis
ts()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Migrations\Migrator.php : 545
17 Illuminate\Database\Migrations\Migrator::repositoryExists()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Database\Console\Migrations\ResetCommand.php : 63
18 Illuminate\Database\Console\Migrations\ResetCommand::handle()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Container\BoundMethod.php : 29
19 call_user_func_array([])
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Container\BoundMethod.php : 29
20 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Container\BoundMethod.php : 87
21 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Founda
tion\Application), Object(Closure))
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Container\BoundMethod.php : 31
22 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Applic
ation), [])
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Container\Container.php : 564
23 Illuminate\Container\Container::call()
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Console\Command.php : 183
24 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input
\ArgvInput), Object(Illuminate\Console\OutputStyle))
C:\Users\jarro\Documents\Sites\homestead\vendor\symfony\console\Command\Co
mmand.php : 252
25 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Co
nsole\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Console\Command.php : 170
26 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\Arg
vInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\Users\jarro\Documents\Sites\homestead\vendor\symfony\console\Applicatio
n.php : 865
27 Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Data
base\Console\Migrations\ResetCommand), Object(Symfony\Component\Console\Input\Ar
gvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\Users\jarro\Documents\Sites\homestead\vendor\symfony\console\Applicatio
n.php : 241
28 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Cons
ole\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\Users\jarro\Documents\Sites\homestead\vendor\symfony\console\Applicatio
n.php : 143
29 Symfony\Component\Console\Application::run(Object(Symfony\Component\Consol
e\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Console\Application.php : 88
30 Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input
\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\Users\jarro\Documents\Sites\homestead\vendor\laravel\framework\src\Illu
minate\Foundation\Console\Kernel.php : 121
31 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Cons
ole\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\Users\jarro\Documents\Sites\homestead\artisan : 37
我想我知道发生了什么。我不得不在PHPStorm中将数据库连接更改为192.168.10.10才能连接到MySQL,因为MySQL位于homestead VM(虚拟机)上,而我无法在本地连接到它,因为从技术上讲,它位于“不同的机器”上。然后我去寻找在哪里更改数据库信息。到目前为止,我的查询工作正常。所以我不知道为什么会有问题。我找到了/config/database.php并将每个用户名、密码、数据库名和主机更改为正确的内容:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '192.168.10.10'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'homestead'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '192.168.10.10'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'homestead'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '192.168.10.10'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'homestead'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'charset' => 'utf8',
'prefix' => '',
],
但这并没有真正起作用。我执行了命令
流浪者重新装载——规定
确保这不是问题。它在终端的错误信息中说
2
PDO::__construct("mysql: host=127.0.0.1; port=3306; dbname=homestad","家庭tead","秘密",[])
127.0.0.1
当我明确地将/config中database.php文件中的主机更改为192.168.10.10时,这在尝试连接phpstorm时有效。
我很难学习laravel,我不知道如何将它改为192.168.10.10。有经验的人或至少有人能告诉我正确的方向,帮助我找到变量$dsn来更改传入的主机吗?
任何帮助都很感激!
尝试在根文件夹中编辑. env文件或在根文件夹中编辑.env.example文件
尝试运行php artisan缓存:清除
或php artisan配置:清除
您还可能有一个.env文件覆盖它。
问题内容: 我调试代码时突然发生错误。它具有与数据库连接有关的一系列错误。 这是错误所指向的代码 我不知道该怎么办,因为我通常不会遇到这样的问题,所以我对WAMP的研究并不多。感谢您的帮助。 问题答案: 如果WAMP图标为橙色,则其中一项服务尚未启动。 在您的情况下,由于您收到的消息表明 没有服务器在运行 ,因此MySQL尚未启动,因此正在侦听请求。 查看mysql日志,如果没有告诉您任何信息,请
所以我想部署我现有的laravel porject到我的digitalOcean vps我用户这个啧啧,我上传我的网站成功 我的环境文件也是 但问题是 我使用mysql创建并运行了,得到了这些错误,问题出在哪里 [Illumb\Database\QueryException]SQLSTATE[HY000][2002]连接被拒绝(SQL:select*from information\s chema
使用Mac OS X和2.2.1与Laravel 5.2. 在终端中(在我的项目文件夹中的homestead中),我可以使用php artisan查看所有可用的命令。当我尝试运行php artisan migrate时,我收到一个连接错误: 我已经设置了一个Laravel项目与这些. env设置 我还尝试了localhost作为DB\u主机,root作为DB\u用户名和DB\u密码。把所有可能的变
问题内容: 我正在尝试使用PHP连接来连接phpmyadmin上的MySQL数据库。只是尝试查看连接是否成功,对连接没有什么幻想。我正在使用MAMP托管数据库,我尝试使用的连接是这样的: 我一直在使用邮递员进行测试,以查看连接是否正常工作,但是我一直收到以下错误消息: 连接失败:SQLSTATE [HY000] [2002]连接被拒绝 在收到以下错误消息之前: 连接失败:SQLSTATE [HY0
我正在尝试重新连接本地实例,但收到此错误,可能的解决方法是什么?(“无法连接到任何服务器”,{'127.0.0.1:8000':连接已更新错误(10061,“已尝试连接到 [('127.0.0.1',6000)]。最后一个错误:无法建立连接,因为目标计算机主动拒绝了它“)}) 我的 docker-compose.yml 文件看起来像这个网络: 应用层: 驱动程序: 桥 服务: cassandra:
问题内容: 每次尝试运行程序时,我都尝试连接到本地计算机。我是一个小人物,所以在某个地方可能是一个简单的错误。 那就是导致错误的代码。主机和端口已定义。为什么会给我这个错误报告? [Errno 10061]无法建立连接,因为目标计算机主动拒绝了它 问题答案: 这是因为您尚未打开要连接的端口,所以那里没有监听。如果您尝试连接到Web或ftp服务器,请先启动它。如果您尝试连接到另一个端口,则也需要编写