Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql cannot connect - Access denied (using password yes)

Tags:

php

mysql

cpanel

I have hosting provided by eleven 2 and I just created a new MySQL user and gave it access to every action listed.

I'm getting the following error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user '(username is here, removed for posting)' (using password: YES) in /home/.../public_html/config.php on line 10

Here is my config file

//connection details have been removed for posting purposes

<?php

 define('SQL_SERVER',''); // Database Server
 define('SQL_USER',''); //  User
 define('SQL_PASS',''); //  Password
 define('SQL_DB',''); //  database



 mysql_connect(SQL_SERVER,SQL_USER,SQL_PASS) or die("Error: ".mysql_error()); // Connection to the server
 mysql_select_db(SQL_DB) or die("Error: ".mysql_error()); // Connecting to the database
?>

I tried to do the following as suggested by this post Access denied for user 'someuser'@'localhost' (using password: YES)

GRANT ALL PRIVILEGES ON databasename.* TO 'bookorama'@'%' IDENTIFIED BY 'yourpassword';
FLUSH PRIVILEGES;

But I got the following error "#1044 - Access denied for user". When I log into the CPanel and check out the database users, it shows the user that I tried to log in as, so I'm confused as to why it won't work.

EDIT - I got it to work. There was something wrong with the server. Contacted the host and they took care of it. Thanks for the replies.

like image 671
user1443519 Avatar asked Sep 28 '12 02:09

user1443519


People also ask

How do I fix yes access denied for password?

To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password'; Replace user_name with the user's username and password with the user's password.

How do I fix access denied for localhost using password no?

Use the ALTER USER command and change the authentication method to log into MySQL as root: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; This command changes the password for the user root and sets the authentication method to mysql_native_password.

How do I fix error 1045 28000 Access denied?

How to fix “Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes)”? It arises when you perform a fresh installation of MySQL and try to login with a password. The default password of MySQL is blank () (i.e. empty string). So, you can login to the MySQL server using the same password.


1 Answers

I stumbled upon this connection info about Cpanel http://www.inmotionhosting.com/support/community-support/databases/1045-access-denied-for-user-mysql-error

Your cPanel username and password can be used to connect to your databases (as well as your cPanel). If you're connecting to your database using your cPanel username and password, you can reset your cPanel password to ensure you are using the correct username and password.

If you setup a MySQL username and password specifically for accessing a database, you'll want to ensure you are using the correct username in your php scripts. For example, MySQL usernames are always in this format:

cpanel-username_mysql-username

If your cPanel username is userna5 and you created a database username of dbuser1, then the actual database username would be:

userna5_dbuser1

Temporarily, I'd suggest changing your databse password to that of your Cpanel account just to eliminate any doubts.

like image 177
user1104854 Avatar answered Nov 06 '22 21:11

user1104854