开发者

Access denied for user 'someuser'@'localhost' (using password: YES)

开发者 https://www.devze.com 2023-02-26 20:38 出处:网络
I have created a database by name \'somedatabase\' in mysql CREATE DATABASE somedatabase; GRANT ALL ON somedatabase.* TO \'someuser\'@\'localhost\' IDENTIFIED BY \'somepassword\';

I have created a database by name 'somedatabase' in mysql

CREATE DATABASE somedatabase;  
GRANT ALL ON somedatabase.* TO 'someuser'@'localhost' IDENTIFIED BY 'somepassword';

but when i try to access this database using php application i get the following error

"mysql_connect() [function.mysql-connect]: Access denied for user 'someuser'@'localhost' (using password: YES)"

The Mysql query browser does allow me to login to this database using username : someuser and password : somepassword. Then why is that i am not able to connect to database through application.

php code :

$db_url = 'mysql://someuse开发者_运维问答r:*somepassword*@localhost/somedatabase';


Do not use singlequote (') around someuser when using GRANT.

GRANT ALL ON somedatabase.* TO someuser@'localhost' IDENTIFIED BY 'somepassword'; 

I am also assuming that you're running Apache/PHP on the same box as MySQL.


I had same problem. the solution of my problem by was setting the host , for some reason php was not connecting for user at any host (%)


Try this: GRANT ALL PRIVILEGES ON somedatabase.* TO 'someuser'@'%' IDENTIFIED BY 'somepassword';

http://dev.mysql.com/doc/refman/4.1/en/adding-users.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号