0

I have install mariadb 10.2 on Digitalocean droplet. I have created test@localhost user and granted access to test database.

With test user I can able log into mysql console.

But when I am trying to connect to database from my Yii2 Application, access denied with password arises.

I have run mysql_secure_connection script to block root access from outside.

My DB Config -

Database Component Config:

return [
    'class' => 'yii\db\Connection', 
    'dsn' => 'mysql:host=localhost;dbname=test', 
    'username' => 'test', 
    'password' => 'test@123', 
    'charset' => 'utf8',
];

Does anyone has any idea.

6
  • You must be sending the wrong password in the application. Commented Apr 13, 2018 at 20:03
  • where is your database component configuration add it to your question? Commented Apr 13, 2018 at 20:56
  • Database Component Config - return [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=test', 'username' => 'test', 'password' => 'test@123', 'charset' => 'utf8', ]; Commented Apr 14, 2018 at 4:05
  • try adding it into the question not in comments Commented Apr 14, 2018 at 10:57
  • Were you able to resolve your issue? Commented Apr 17, 2018 at 21:05

2 Answers 2

1

use localhost:3306 instead of using host=local

Sign up to request clarification or add additional context in comments.

Comments

0

Try addin a new db user and use % for any host. See if you still are receiving the error. Attempt to connect to your DB via MySQL workbench, verify your credentials.

Did you deny remote access?

'db' => [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost; dbname=somedb',
    'username' => 'root',
    'password' => 'passw0rd',
    'charset' => 'utf8',
]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.