ohgod
(Tom)
November 1, 2017, 11:46pm
1
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
tri
(tri - Tommy Riboe)
November 2, 2017, 12:08am
2
Add permissions for user to the db table.
ohgod
(Tom)
November 13, 2017, 1:28am
3
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)
thadude
(Thadude)
January 12, 2018, 12:02pm
4
did you initialize the environment?
php init
ohgod
(Tom)
January 15, 2018, 2:01am
5
Yes. Tried as both dev and prod environments, followed the tutorial.
evstevemd
(Stefano Mtangoo)
January 17, 2018, 10:34am
6
It means you are using wrong username or password
bobonov
(Bobonov)
January 18, 2018, 6:07pm
7
I guess you are talking about MySQL console. This is because you miss ; at the end of your SQL command
To check if db permission are fine try using mysql via shell
mysql -u <username> -p<password> <dbname>
Note that after -p there is no space
If you can connect via shell the problem is in yii config
Hi friends i got the same issue, but i don’t use password in the phpmyadmin
i want to learn yii2, and try to install basic template project.
and the first things that i want to make is a migration.
but i got some issue that i can’t fix, already try to search the solution.
i guess i don’t have problem in phpmyadmin
but i got error when i try to make migration in yii2,
i use vscode to ru n the command line, and xampp for the server.
so what do you think for this issue, please help me to fix this error.
this is my phpmyadmin user account
evstevemd
(Stefano Mtangoo)
July 4, 2022, 8:24am
10
Hi David, Please open new thread when you have a problem instead of writing on top of existing thread.
As error says you have wrong credentisla in your config/db.php
file. Fix that and it will work