Reputation: 4571
I am trying to connect to my phpMyAdmin database called "db", but I am getting the following error:
username@servername:~$ mysql -u username -p password
Enter password: (I enter my password)
ERROR 1044 (42000): Access denied for user 'username'@'localhost' to database 'password'
I am pretty sure that my username and password are correct, and that I have the privileges to access the database. What's confusing me is this part:
database 'password'
since that's not the name of my database. The db.php file looks like this:
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=db',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'tablePrefix' => 'uni_',
];
Upvotes: 1
Views: 3287
Reputation: 4396
You're messing up the mysql
command. You're connecting to a database called password
and not giving the actually password. You should do this:
mysql -u username -ppassword
or this:
mysql -u username --password=password
The reason for this is that if a space follows the option letter, the program has no way to tell whether a following argument is supposed to be the password value or some other kind of argument.
Check it out here.
Upvotes: 6