Access denied for user at localhost

Hi guys.

We can can connect to mysql server from command line with some user. but when using mysql_connect() it says:

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

what should i do?

Need more information, but if you are using PHP then look at your PHP.INI file to make sure you are loading the Mysql Modules.

here is my php.ini file:

Could you post the exact working command and its output and the exact error message you're getting when you try to connect using php?

ok!

here is my mysql user: root1
i can connect to a sample database from command line, mysql workbench, phpmyadmin and browse the database but when using mysql_connect to connect to the same database it gaves me this error:

Make sure you have the correct username and password, if you are sure you have the correct login and pasword, then you need to check with your administrator because you seem to have either the wrong login id or password and that's why your script cannot connect to your mysql database.

check these four things to make sure you have them right:

  1. your hostname (Make sure your database is on the machine you are trying to run the php from and is configured for"localhost")
  2. your database username (not your hosting username, BUT your mysql)
  3. Your database password
  4. Your database name
  5. your port is the same port as used in command line.

I suppose that the working connections are remote (they are coming from a remote host). You should explicitly grant access from localhost:

grant ... on yourdb.* to root1@localhost identified by 'your_password';