I use Yii2, db connection
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=localhost;dbname=data-storage',
'username' => 'data-storage',
'password' => '',
'charset' => 'utf8',
]
My database does not have a password. I got an error: SQLSTATE[08006] [7] fe_sendauth: no password supplied.
If I use some password (just fake, as I mentioned I don't have it) I'm getting: password authentication failed for user "data-storage"
In pg_hba.conf I have a record for my domain:
host all all 172.28.3.70/32 trust
Which works fine for PgAdmin.
I figured it out, I have used localhost instead of the server IP where the database is located.
try this
return [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=localhost;dbname=db_name',
'username' => 'db_username',
'password' => NULL,
'charset' => 'utf8',
'schemaMap' => [
'pgsql'=> [
'class'=>'yii\db\pgsql\Schema',
'defaultSchema' => 'public' //specify your schema here
]
], // PostgreSQL
];
or remove password.
Related
I want to use mail host with mailtrap and I've sign up my gmail account in mailtrap.io and copy paste my credentials in my .env file like this :
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=d60830b6f51e71
MAIL_PASSWORD=0e117cca06c205
MAIL_ENCRYPTION=tls
And this is my mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.io'),
'port' => env('MAIL_PORT', 2525),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('d60830b6f51e71'),
'password' => env('0e117cca06c205'),
But, when I click the send reset password links, it says "Connection could not be established with host smtp#gmail.com :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup."
Can someone help me?
I am trying to query an additional external database connection in one of my repositories. In LocalConfiguration.php I've defined two connections (Default, External).
[...]
'DB' => [
'Connections' => [
// Local MySQL database
'Default' => [
// ...
],
// External MSSQL database
'External' => [
'charset' => 'utf-8',
'dbname' => 'DBNAME',
'driver' => 'sqlsrv',
'host' => 'someExternalIP',
'password' => 'somePassword',
'port' => 1433,
'user' => 'someUser',
],
],
],
[...]
In my repository I want to query the external database (via Doctrine).
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('dbo.SomeTable');
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder
->select('*')
->from('dbo.SomeTable');
Do I have to explicitly tell the QueryBuilder to use that particular connection? Right now I am getting an Doctrine\DBAL\Exception\ConnectionException error, as the system tries to connect via the Default-Connection.
An exception occurred while executing 'SELECT * FROM `dbo`.`SomeTable`':
SELECT command denied to user 'myLocalUser'#'localhost' for table 'SomeTable'
Check out $GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping'] where you can explicitly define what tables are located in which database. See also this for some more details https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Database/Configuration/Index.html
The other option is actually to use ask the Connection by name, and create a query builder out of that.
GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionByName('External')->createQueryBuilder(...)
I personally would go with the latter, as it is more explicit within the actual callers code what is used.
To work with external DB, you have to :
configure the mapping with external database and table mapping in LocalConfiguration.php
define the TCA for external tables in myExt/Configuration/TCA/MyExternalTableName.php
configure the external tables/columns mapping in ext_typoscript_setup.txt
and then, the queries in repositories will work.
Sample LocalConfiguration.php :
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf8',
'dbname' => 'LOCAL-DB',
'driver' => 'mysqli',
'host' => '127.0.0.1',
'password' => 'PWD',
'port' => 3306,
'user' => 'USER',
],
'externalDb' => [
'charset' => 'utf8',
'dbname' => 'EXTERNAL-DB',
'driver' => 'mysqli',
'host' => 'localhost',
'password' => 'PWD',
'port' => 3306,
'user' => 'USER',
],
],
'TableMapping' => [
'MyexternalTable1' => 'externalDb',
'MyexternalTable2' => 'externalDb',
...
]
]
Sample columns mapping in myExt/ext_typoscript_setup.txt :
plugin.tx_myext {
persistence {
classes {
Vendor\MyExt\Domain\Model\LocalModel {
mapping {
tableName = ExternalTableName
recordType = \Vendor\MyExt\Domain\Model\LocalModel
columns {
col1.mapOnProperty = uid
col2.mapOnProperty = name
...
}
}
}
}
}
}
I have a domain: www.mydomain.ro and i created an email like this: office#mydomain.ro
I'm trying to send emails from my laravel application(laravel 5.7) and i did this configurations:
In .env file:
MAIL_DRIVER=smtp
MAIL_HOST=office#my-domain.ro
MAIL_PORT=26
MAIL_USERNAME=office#my-domain.ro
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=null
And in config/mail.php:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'mail.my-domain.ro '),
'port' => env('MAIL_PORT', 26),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'office#muy-domain.ro'),
'name' => env('MAIL_FROM_NAME', 'Office my-domain'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('office#my-domain.ro'),
'password' => env('mypassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
In Controller i'm doing this:
$data = array(
'name' => 'Ioan Andrei',
'body' => 'Test Email'
);
Mail::send('emails.demandreceived',$data,function ($message){
$message->from('office#my-domain.ro','TEST');
$message->to('ioan.andrei97#gmail.com');
$message->subject('Test email');
I get this error:
Connection could not be established with host office#msipremiumcars.ro [php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known #0]
What am i doing wrong?It's not working beacuse i'm trying to send them from my local server?
Can i use mailgun for example to send the email and still have the email send from office#mydomain.ro?
I tried to restart my local server after configs.
Laravel version: 5.7
The issue is the MAIL_HOST in the .env file. It needs to be hostname like my-domain.ro instead of an email address as you've currently entered office#my-domain.ro.
For a project I use Slim 3 - Twig and Eloquent. On development mode, all works perfectly, but on production, hosted in the OVH shared server, I can't access to the database.
I'm hundred percent sure of credentials and the database was not created right now.
This is my code :
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($config['db']);
$capsule->bootEloquent();
$capsule->setAsGlobal();
Where $config['db'] contains the informations required by Eloquent :
$config = [
'settings' => [
'debug' => true,
'displayErrorDetails' => true
],
'db' => [
'driver' => 'mysql',
'host' => '****.mysql.db',
'database' => '****',
'username' => '****',
'password' => '****',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
]
]
What I have to do to make it work ?
Ok ... I get the solution.
... Suspense ...
I have to remove spaces around the big arrows in my beautiful formatted array.
Yes. I'm gonna cry.
I don't know how to troubleshoot this. It works locally but not on my godaddy server. Where can I get all my variable options for SSL
I found an answer here I want to try
PHPMailer GoDaddy Server SMTP Connection Refused
It says I have to use
SMTP_SERVER: smtpout.secureserver.net (or alternatively relay-hosting.secureserver.net)
SMTP_PORT: 465 //or 3535 or 80 or 25
SMTP_AUTH: true //always
SMTP_Secure: 'ssl' //only if using port 465
How do I set these values with the transport.
I know port is 'port' and 'SMTP_SERVER' is 'host'
but is 'SMTP_AUTH', 'auth'?
/*Email Transport*/
'EmailTransport' => [
'gmail' => [
'host' => 'ssl://smtp.gmail.com',
//'host' => 'relay-hosting.secureserver.net',
//'host' => 'ASPMX.L.GOOGLE.COM',
//'host'=>'smtpout.secureserver.net',
'port' => 465,
'username' => '-----#gmail.com',
'password' => 'password',
'className' => 'Smtp',
'log' => true,
],
],
'Email' => [
'default' => [
'transport' => 'gmail'
],
I think that you cannot set that option in the array because the SMTP Transport class handles it internally. Check the code please of the class.
https://api.cakephp.org/3.3/source-class-Cake.Mailer.Transport.SmtpTransport.html#241-268
This works fine here. CakePHP will automatically use SMTP AUTH when you specify username and password. SSL will be used by prefixing the host with ssl:// and the appropriate port as you did.
'Email' => [
'default' => [
'transport' => 'gmail'
]
],
'EmailTransport' => [
'gmail' => [
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'googleUserNameWithout', //without the #gmail.com
'password' => 'P4ssw0rd',
'className' => 'Smtp'
]
]