Error when running :
运行时错误:
php artisan migrate:reset
php工匠迁移:重置
in the root of my Laravel site:
在我的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.
When i ran the -v i got this:
当我运行-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
I think i know what is going on. I have had to change my database connection to 192.168.10.10 in PHPStorm to connect to MySQL because the MySQL is on the homestead VM (virtual machine) and i cant connect to it locally because technically its on a "Different Machine". So then i went looking for where to change database info. My queries work as of now. So i don't know why this is having issues. I found the /config/database.php and changed every username, password, db name, host to the correct things :
我想我知道发生了什么。在PHPStorm中,我不得不将数据库连接改为192.168.10.10才能连接到MySQL,因为MySQL位于homestead VM(虚拟机)上,我无法在本地连接到它,因为从技术上讲,它位于“不同的机器”上。然后我就去找可以改变数据库信息的地方。我的问题到目前为止还有效。我不知道为什么会有问题。我发现/ config /数据库。php并更改了每个用户名,密码,db名称,主机到正确的东西:
'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' => '',
],
But this, didn't really help. I did the command
但这并没有什么帮助。我的命令
vagrant reload --provision
流浪的重载,提供
to make sure that wasn't an issue. It is saying in the error message in the terminal
确保这不是问题。在终端的错误信息中
2
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=homestead", "homes tead", "secret", [])2 PDO::__construct(“mysql:host=127.0.0.1;port=3306;dbname=homestead”,“homestead”,“secret”,[])
127.0.0.1
127.0.0.1
When i clearly changed the host in the database.php file in the /config to 192.168.10.10, which works when trying to connect with phpstorm.
当我清楚地改变数据库中的主机时。php文件在/config中的192.168.10.10中,在尝试连接phpstorm时可以使用。
I am having a hard time learning laravel and i am confused on how to get this changed to 192.168.10.10. Can an experienced person or at least anyone try to tell me the right direction to help me find the variable $dsn to change the host being passed in it?
我学习laravel很困难,我不知道如何把它改成192.168.10.10。一个有经验的人或者至少任何人能告诉我正确的方向来帮助我找到变量$dsn来改变在其中传递的主机吗?
Any help is appreciated!
任何帮助都是赞赏!
1 个解决方案
#1
0
Try running php artisan cache:clear
or php artisan config:clear
尝试运行php artisan缓存:clear或php artisan配置:clear
You might also have a .env file overriding it possibly.
您可能还有一个.env文件覆盖它。
#1
0
Try running php artisan cache:clear
or php artisan config:clear
尝试运行php artisan缓存:clear或php artisan配置:clear
You might also have a .env file overriding it possibly.
您可能还有一个.env文件覆盖它。