Mysql cannot connect - access is denied (using password yes)

I have a hosting provided by eleven 2, and I just created a new MySQL user and gave him access to each specified action.

I get 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 configuration 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 the following as this post suggested 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 is denied to the user." When I log into CPanel and check the database users, it shows the user I was trying to log in with, so I'm confused about why it won't work.

EDIT - I got it to work. Something is wrong with the server. They turned to the owner, and they took care of this. Thanks for answers.

+6
source share
4 answers

I came across this cpanel connection information http://www.inmotionhosting.com/support/community-support/databases/1045-access-denied-for-user-mysql-error

You can use your cPanel username and password to connect to your databases (as well as your cPanel). If you connect to your database using the cPanel username and password, you can reset the cPanel password to make sure that you are using the correct username and password.

If you are setting up the MySQL username and password specifically for accessing the database, you must make sure that you use 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 the database username dbuser1, then the actual database username will be:

userna5_dbuser1

For the time being, I suggest changing the password of my database to my Cpanel account to eliminate any doubts.

+8
source

Usually a password field is not required unless you have set a password for mysql.

you can use mysql_connect ("hostname", "username", "")

But if you set a password for your mysql, then you need to write a password when connecting. And if it still doesn't work, you may have to look at your username and password.

+3
source

What is your sql server? some companies change the server name from the local host to something else for security reasons. Well, but if his denial of access for a user who may be yours connects to the wrong database? i.e

 mysql_select_db(SQL_DB) 

Are you sure you are using the correct database name? and can you log in to your SQL account with the same username and password? well, if the problem still persists while trying to use the root SQL account, the super administrator hopes that you are on your local computer or have a dedicated server.

Why don't you try using them in this form -

 $con = mysql_connect("host name","username","password"); $db = mysql_select_db("database name",$con); 
+1
source

I had the same problem, I tried to connect between two different web servers. If I use my PHP script on the same server, the connection will be established, but if I use the same script file from another web server (web hosting), it gave this error.

I solved this by allowing access to MySQL Server (remote MySQL) by providing an IP address from where I was connected.

It is also worth noting that I used Domain, but Domain Name did not work for me. Both CPanel and MySQL users can connect to MySQL Server. Hope this is useful for you too.

+1
source

Source: https://habr.com/ru/post/926465/


All Articles