Yii Framework Forum: Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)' - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)' Exception 'yii\db\Exception' with message 'SQLST Rate Topic: -----

#1 User is offline   ohgod 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 01-November 17

Posted 01 November 2017 - 06:46 PM

What steps will reproduce the problem?

following tutorial code(dot)tutsplus(dot)com /tutorials/building-your-startup-with-php-feature-requirements-and-database-design--cms-22618

install yii, make a database, user, put the credentials in \environments\dev\common\main-local.php

<?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=your-db',
'username' => 'your-username',
'password' => 'your-pwd',
'charset' => 'utf8',
],
then run ./yii migrate/up 1

What is the expected result?

Creating migration history table "migration"...done.
Total 1 out of 15 new migrations to be applied:

What do you get instead?

Error: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
on clearlinux web server

-or-

Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)'
on Ubuntu localhost

Additional info

Q A
Yii version 2.0.?
PHP version 5.6.31 and/or 7.1.8
Operating system Ubuntu 17.10 and/or CloudLinux
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,824
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 01 November 2017 - 07:08 PM

Add permissions for user to the db table.
Don't forget to read The Definitive Guide to Yii (1.1 en) (1.1 sv) (2.0 en) | The class reference (1.1) (2.0) has the details
0

#3 User is offline   ohgod 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 01-November 17

Posted 12 November 2017 - 08:28 PM

You're gonna have to be really specific. I of course GRANTED all permissions to root and my user, and FLUSHED privileges.

If I run

GRANT ALL PRIVILEGES ON 'dbname' TO 'usernameicreated'@'localhost'

or

GRANT ALL PRIVILEGES ON 'dbname'.* TO 'usernameicreated'@'localhost'

I get no response. It just goes to another line with prompt > like nothing happened.

Here are the permissions:

*************************** 1. row ***************************
Host: localhost
Db: dbname
User: root
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Execute_priv: Y
Event_priv: Y
Trigger_priv: Y
1 row in set (0.00 sec)


*************************** 1. row ***************************
Host: localhost
Db: dbname
User: usernameicreated
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Execute_priv: Y
Event_priv: Y
Trigger_priv: Y
1 row in set (0.00 sec)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users