سؤال

I'm really having a strange Issue here, and it's really starting to annoy me. It's about the different behaviour of connections. I'm just trying to set up CakePHP, but the PDO cant conenct to the mysql Server.

Okey, step by step: It's a fresh computer, I just installed XAMPP (on Win7) and downloaded CakePHP. Nothing else was done. On phpMyAdmin, I created a user 'test' with PW 'test' and he owns the Database 'test'. Simple, right?

Here, the row of the User / Rights table in phpMysqlAdmin:

User Host Password Global Rights GRANT
test %    Yes      USAGE         No

Now, to the real Issue:

This works:

$link = mysql_connect('localhost', 'test'); //<- not using the 3. parameter, 'password'

But, what should work, doesnt:

$link = mysql_connect('localhost', 'test', 'test'); //<- using the 3. parameter, 'password'

And since I cant seem to 'remove' the 'using Password: YES' for PDO's, I cant connect with PDO's either (and cake Uses PDO's):

$dbh = new PDO('mysql:host=localhost;dbname=test', 'test', 'test');

Error Messages:

Error!: SQLSTATE[28000] [1045] Access denied for user 'test'@'localhost' (using password: YES)

It cant be so complicated, I just want to connect to a freshly installed DB, with the correct credentials. What am I doing wrong? I read trough many similar Questions, but didnt find a solution for my own Problem.

And yes, the password really is 'test' - I have no idea why the mysql_connect() whitout PW, can connect - is it using the username as PW by default?

This really cant be that hard

Thanks for the help, Wish you a nice day.

EDIT (answer to question)

Here the entry for the DB rights (in user: test): - the user really seems to have all rights for DB 'test'

Database Rights         GRANT 
test     ALL PRIVILEGES Nein
هل كانت مفيدة؟

المحلول

GRANT ALL ON test.* TO test@localhost IDENTIFIED BY "test";

Run the above query at the mysql shell and everything should work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top