When running php artisan migrate, It gives following error message:
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for http failed: No such host is known. (SQL: select * from information_schema.tables where table_schema = my_art_stock and table_name = migrations and table_type = 'BASE TABLE')
at C:\Users\installerjoe\laravel-projects\myArtStock-project\vendor\laravel\framework\src\Illuminate\Database\Connection.php:712
708▕ // If an exception occurs when attempting to run a query, we'll format the error
709▕ // message to include the bindings with SQL, which will make this exception a
710▕ // lot more helpful to the developer instead of just the database's errors.
711▕ catch (Exception $e) {
➜ 712▕ throw new QueryException(
713▕ $query, $this->prepareBindings($bindings), $e
714▕ );
715▕ }
716▕ }
1 C:\Users\installerjoe\laravel-projects\myArtStock-project\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo for http failed: No such host is known. ")
2 C:\Users\installerjoe\laravel-projects\myArtStock-project\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct("mysql:host=http://art-stock-db.cujslgoio4sv.us-east-2.rds.amazonaws.com/;port=3306;dbname=my_art_stock", "stockadmin", "indianopen11*", [])
Please what causes this error, server configurations or laravel configuration? I'd really appreciate if someone offers a solution to this error.
Related
I'm trying to connect the MySQL database in Laravel, having some issues.
This is MySQL credentials in the .env file in Laravel.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=welcome
DB_USERNAME=krishna
DB_PASSWORD=Krish_123
I'm trying to migrate it's shown some error like bellow.
siva#siva-Latitude-3490:~/Desktop/laravel-practies-project$ php artisan migrate
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = welcome and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
+34 vendor frames
35 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
I am uploading a file to Alibaba Cloud - OSS bucket. Have correct access key and secret key.
Using oss-sdk-php through yii2, Getting Error
{"name":"PHP Fatal Error","message":"Uncaught exception
'OSS\Core\OssException' with message 'RequestCoreException: cURL
resource: Resource id #351; cURL error: Failed to connect to
chinaproduct.oss-cn-beijing.aliyuncs.com port 80: Connection timed out
(7)'
Unable to get exact issue, any help would be appreciated.
// #### Delete old files / Fetch all files with prefix
$listObjectInfo = $ossClient->listObjects($productBucket,array('prefix'=>$uploadProductPrefix));
$objectList = $listObjectInfo->getObjectList();
foreach ($objectList as $objectInfo) {
$fileNameToDelete = $objectInfo->getKey();
$ossClient->deleteObject($productBucket,$fileNameToDelete);
\Yii::info("OSS : Deleted file from OSS -$productBucket - $fileNameToDelete");
}
} catch (OssException $e) {
\Yii::info("OSS : Unable to delete old files from OSS $productBucket for dataId $dataId " . $e);
}
I need to establish an SSL connection between MySQL server and PHP web application.
Currently we are working with offline server (wampserver) and we need to establish an SSL connection. Th moment I changed the connection script from:
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->exec("SET CHARACTER SET utf8mb4");
To:
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass, array(
PDO::MYSQL_ATTR_SSL_KEY =>'/etc/mysql/ssl/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT=>'/etc/mysql/ssl/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA =>'/etc/mysql/ssl/ca-cert.pem'
));
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->exec("SET CHARACTER SET utf8mb4");
an error appeared on the login page saying:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2006] MySQL server has gone away' in C:\wamp64\www\
EDIT
I run this query:
show variables like '%ssl%'
And got the following result:
I am using Symfony 3.0.4. I have the error
[2016-05-20 08:50:26] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: "An exception occured in driver: SQLSTATE[HY000] [2002] No route to host" at /var/www/WebProduction/products.markettraders.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 103 {"exception":"[object] (Doctrine\\DBAL\\Exception\\ConnectionException(code: 0): An exception occured in driver: SQLSTATE[HY000] [2002] No route to host at /var/www/WebProduction/products.markettraders.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:103, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No route to host at /var/www/WebProduction/products.markettraders.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2002): SQLSTATE[HY000] [2002] No route to host at /var/www/WebProduction/products.markettraders.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []
[2016-05-20 08:50:26] security.DEBUG: Stored the security token in the session. {"key":"_security_main"} []
This is strange because the indexAction is working perfectly, only the Edit Action is NOTWorking, on all of my edit routes. There have been no changes in the code to cause this to happen.
What have I inadvertantly changed in my MySQL configuration that allows Doctrine to find everything on the indexAction but then error out on the editAction?
EDIT
Forgive me.... The code is below. It works in my local environment. It does not work in prod. The error above comes from the prod.log.
In addition the indexAction controller works as well.
/**
* Displays a form to edit an existing AOD Technical Analysis page entity.
*
* #Route("/{id}/edit", name="aod_technical_analysis_edit")
* #Method({"GET", "POST"})
*/
public function editAction(Request $request, AodTechnicalAnalysis $aod_tech)
{
$deleteForm = $this->createDeleteForm($aod_tech);
$editForm = $this->createForm('AppBundle\Form\AodTechnicalAnalysisType', $aod_tech);
$editForm->remove('currencypair');
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($aod_tech);
$em->flush();
$session = $request->getSession();
$message = 'The change was succesfully saved for ' . $aod_tech->getCurrencypair();
$session->getFlashBag()->add('success', $message);
return $this->redirectToRoute('aod_technical_analysis_index');
}
return $this->render('aod_tech/edit.html.twig', array(
'aod_tech' => $aod_tech,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
Have you tried appending "app_dev.php" on your URL to get the debug web toolbar? I have found this to be more helpful compared to logs. You might need to edit the "web/app_dev.php" to add your browser's IP address.
How can I check whether database host is valid?
try {
Yii::app()->db;
} catch (Exception $ex) {
echo $ex->getMessage();
}
Code above gives me this error when I use invalid host address:
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known.
I just want to receive something that returns false, so I could display my own error message