on a machine with IP 178.33.13.83, i have a symfony app with the following parameters.yml :
parameters:
database_host: 178.33.13.80
database_port: null
database_name: alterxtn
database_user: alterxtn
database_password: ********************
But then when i try to doctrine:schema:update i recieve the following exception :
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [1045] Access denied
for user 'alterxtn'#'178.33.13.83' (using password: YES)
I'm wondering why it's trying to connect to the machine the app is installed on and not on the database_host
[Edit 1]:
here the exception with stacktrace, and please notice especially the Driver->connect() function that's taking the good params :
ConnectionException in AbstractMySQLDriver.php line 103:
An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'alterxtn'#'178.33.13.83' (using password: YES)
in AbstractMySQLDriver.php line 103
at AbstractMySQLDriver->convertException('An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'alterxtn'#'178.33.13.83' (using password: YES)', object(PDOException)) in DBALException.php line 145
at DBALException::driverException(object(Driver), object(PDOException)) in Driver.php line 47
at Driver->connect(array('driver' => 'pdo_mysql', 'host' => '178.33.13.80', 'port' => null, 'dbname' => 'alterxtn', 'user' => 'alterxtn', 'password' => '**********************************', 'charset' => 'UTF8', 'driverOptions' => array(), 'defaultTableOptions' => array()), 'alterxtn', '******', array()) in Connection.php line 360
[EDIT 2] :
i have the same error in shell so probably not a symfony problem
me#mymachine:$ mysql -h 178.33.13.80 -u alterxtn
ERROR 1045 (28000): Access denied for user 'alterxtn'#'178.33.13.83' (using password: YES)
It was my mistake.
The sql-user was set to server-privilege localhost
Setting it to % solved the issue.
Related
I have a Cakephp3.8 website, connected to a RDS database. I am trying to use an SSL database connection.
I got the pem certificate from AWS. I have created a test user with access to my database, and this user is set up to require SSL.
I can successfully connect to the database with my user from the command line:
mysql -u ssl-user -p -h xxxxx.xxxxx.ap-southeast-2.rds.amazonaws.com --ssl-ca=./rds-ca-2019-root.pem
I have set up my database connection in CakePHP as follows:
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'xxxxx.xxxxx.ap-southeast-2.rds.amazonaws.com',
'username' => 'sl-user',
'password' => 'xxxxxxx',
'database' => 'xxxxxxx',
'ssl_ca' => '/var/www/rds-ca-2019-root.pem',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
'quoteIdentifiers' => true,
'url' => env('DATABASE_URL', null),
],
],
With the above setup I the connection fails and I get the following error:
Error: [PDOException] SQLSTATE[HY000] [2002]
Caused by: [PDOException] PDO::_construct(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_sertificate:certificate verify failed (/var/www/vendor/cakephp/cakephp/src/Database/Driver.php:92)
Any ideas why CakePHP can't connect?
Actually realised that the RDS server was running MariaDB 10.3.x. AWS provide specific docs for MariaDB: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MariaDB.html#MariaDB.Concepts.SSLSupport
The solution for me was to use the combined certificate:
https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
Most answers were that it would be a right issue. But I assume not in this case, because mysql-connection still worked.
I am trying to connect to a mariadb10, which was on a server in my network
I am trying to connect from my localhost.
If I try in my terminal:
myuser#mylocalComputer ~ $ mysql -h myserver -P 3307 -u mydbuser -pmyconfidentalpassword
everything works fine!!
But If I try to connect by php scrypt by pdo I get the error:
<?php
$dsn = 'mysql: host=myserver:3307;dbname=mydbname';
$username = 'mydbuser';
$password = 'myconfidentalpassword';
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$dbh = new PDO($dsn, $username, $password, $options);
if(! $dbh ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'select * from foo;';
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not select data: ' . mysql_error());
}
echo "Synced data successfully\n";
mysql_close($conn);
?>
The Error was:
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1045] Access
denied for user 'mydbuser'#'localhost' (using password: YES) in
/home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php:8
Stack trace:
/home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php(8):
PDO->__construct('mysql: host=myse...', 'mydbuser',
'myconfidentalpassword', Array) {main} thrown in
/home/myuser/Projekte/Hibiscus_extend/Hib_Nightly_sync.php on line 8
What did I do wrong, and where?
Oh Oh Oh!
I found the solution!
The reason for the connection problem were just the empty spaces in $dsn
Wrong:
$dsn = 'mysql: host=myserver:3307;dbname=mydbname';
works fine
$dsn = 'mysql:host=myserver:3307;dbname=mydbname';
I try to implement some unit tests with phpUnit, on a project that uses Eloquent. The installation is made with composer for both frameworks. But when I try to implement a simple example test, it fails loading database.php
the example test
include("database.php");
class ArticleControllerTest extends TestCase
{
public function testAccueil()
{
//récupère la date du jour
$a = \app\model\Article::first();
$this->assertInternalType("string", $a->titreGeneral);
}
}
Database.php
<?php
require 'vendor/autoload.php';
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
$capsule = new Capsule;
$capsule->addConnection(array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'spectacles',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
));
$capsule->setEventDispatcher(new Dispatcher(new Container));
$capsule->setAsGlobal();
$capsule->bootEloquent();
error message with these script (the database is in the right folder)
PHP Warning: include(../../database.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
Warning: include(../../database.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
PHP Warning: include(): Failed opening '../../database.php' for inclusion (include_path='.:') in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
Warning: include(): Failed opening '../../database.php' for inclusion (include_path='.:') in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
And error messages when I try to put the code in database.php directly in the example test :
PDOException: SQLSTATE[HY000] [2002] No such file or directory
I don't think the problem comes prom the paths (they are the right paths). Did I miss something ?
PDOException: SQLSTATE[HY000] [2002] No such file or directory means the database could not connect.
The other errors are clearly telling you that the script could not include the database.php file.
The paths are not correct. You are not properly understanding how include() works. Read http://php.net/manual/en/function.include.php.
In a nutshell, the following code expects the database.php file to exist in the same directory as the file itself, or on the include path.
include("database.php");
class ArticleControllerTest extends TestCase
{
...
These may also help:
Understanding include_path output PHP
Include Config and Database from other files
I am using Chef zero on my windows machine to ssh into a red hat linux machine and execute a command that's inside of a recipe. When I run the code below, it tries to SSH for 120 secs and times out. I'm not sure why this is happening. Any idea why this is happening?
require 'chef/provisioning'
require 'chef/provisioning/ssh_driver'
with_driver 'ssh'
machine "ssh" do
attribute "short_dns", new_resource.short_dns
attribute "long_dns", load_balancer_name
recipe "mycookbook::add_short_dns"
machine_options :transport_options => {
'is_windows' => false,
'ip_address' => '10.16.99.124',
'username' => 'myusername',
'ssh_options' => {
'password' => 'mypassword'
}
}
converge true
end
here is the error
- been waiting 110/120 -- sleeping 10 seconds for ssh (10.16.99.124 on ssh:C:/Users/user/.chef/provisioning/ssh) to be connectable ...[2015-06-23T14:54:33-05:00] INFO: Executing sudo pwd on myusername#10.16.99.124
================================================================================
Error executing action `converge` on resource 'machine[ssh]'
================================================================================
RuntimeError
------------
Machine ssh (10.16.99.124 on ssh:C:/Users/user/.chef/provisioning/ssh) did not become ready within 120 seconds
I'm still fighting with Chef Provisioning myself, so this may not be as helpful as I would like. One thing is that each of these is a key/value pair, so want to declare your variables differently (see below):
require 'chef/provisioning/ssh_driver'
with_driver 'ssh'
with_machine_options :transport_options => {
:username => 'centos',
:ssh_options => {
:password => 'password'
}
}
Amir,
Does the :C/Users/user/.chef/provisioning/ssh directory exist on your workstation? If not try creating it and making sure permissions are correct then try
Try to use the snippet below, notice extra options that will help you to debug an issue.
1) DEBUG level will allow to see SSH communication.
2) If you don't overwrite prefix, it will use SUDO by default
3) Sometimes when you recreate remote server, your "known_hosts" file remembers it and the next time you try to SSH into server after recreation, you receive thie message "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED". In fact SSH session hangs, but you don't see that on the client side. So better ignore it.
:transport_options => {
:is_windows => false,
:username => 'YOURUSER',
:ssh_options => {
:password => 'YOURPASSWRD',
:verbose => Logger::DEBUG,
:user_known_hosts_file => '/dev/null'
},
:options => {
:prefix => ''
}
},
I just begin to start use Selenium with Ruby on Rails 3, I have my code as
before(:all) do
#verification_errors = []
#selenium_driver = Selenium::Client::Driver.new \
:host => "localhost",
:port => 2195,
:browser => "*firefox C:/Program Files (x86)/Mozilla Firefox/firefox.exe",
:url => "localhost:3000",
:timeout_in_second => 60
#selenium_driver.start_new_browser_session
end
after(:all) do
#selenium_driver.close_current_browser_session
#verification_errors.should == []
end
it "should open the create new user page" do
page.open "http://localhost:3000/"
!page.is_text_present("translation missing").should be_false
page.click "link=Register"
page.wait_for_page_to_load "30000"
!page.is_text_present("translation missing").should be_false
page.is_text_present("New Account").should be_true
end
But when I'm trying to run them, I got
11:02:29.118 INFO - Command request: getNewBrowserSession[*firefox C:/Program Files (x86)/Mozilla Firefox/firefox.exe, localhost:3000, , ] on session null
11:02:29.118 INFO - creating new remote session
11:02:29.119 INFO - Allocated session 5cbd2c60271b490ea90eccb193cb1d84 for localhost:3000, launching...
11:02:29.119 ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: java.net.MalformedURLException: unknown protocol: localhost
at org.openqa.selenium.net.Urls.toProtocolHostAndPort(Urls.java:32)
at org.openqa.selenium.browserlaunchers.LauncherUtils.getDefaultRemoteSessionUrl(LauncherUtils.java:121)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.java:413)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRemoteSession(FirefoxLauncher.java:110)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:373)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:87)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:786)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:423)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:394)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:147)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: java.net.MalformedURLException: unknown protocol: localhost
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.openqa.selenium.net.Urls.toProtocolHostAndPort(Urls.java:24)
... 19 more
11:02:29.121 INFO - Got result: Failed to start new browser session: Error while launching browser on session null
I didn't understand how come localhost become an unknown protocol, and I didn't find much help by my own searching.
Can someone help me please, thanks in advance
Localhost is becoming an unknown protocol because you're not specifying any protocol before it, you should change :url => "localhost:3000" to :url => "http://localhost:3000" to include the protocol (http).
Also, (at least on Selenium on Java) one usually uses relative paths when doing the equivalent of page.open.