Everyone wants to make database changes in just one click.
That’s why, phpMyAdmin becomes an inevitable tool for website owners.
However, phpMyAdmin can sometimes show weird errors which are difficult to tackle. One such problem is “Error 1045 in phpMyAdmin“.
At Bobcares, we help server owners resolve these errors as part of our Dedicated Support Services.
Today, let’s discuss the top 2 reasons for this error and how we fix them.
phpMyAdmin error 1045 – A Brief Explanation
Before we move on to the reasons, let’s first get a brief idea of this error.
Customer’s usually see this error when they try to access phpMyAdmin to manage the databases. For instance, users see the following error in the phpMyAdmin interface.
This means that phpMyAdmin tried to connect to the MySQL server, but the server rejected the connection.
phpMyAdmin error 1045 – Causes & Solutions
Now, let’s see the common reasons for this error and how our Support Engineers fix them.
1) Incorrect password
This is the one of the most common reasons for the phpMyAdmin error 1045. A typo in the username or password while accessing the phpMyAdmin panel results in this error.
Similarly, we’ve seen instances where customers reset the MySQL root password or MySQL user password, but forget to update the changes in the phpMyAdmin configuration. This can also create problems.
Solution
Firstly, our Support Engineers get the MySQL username and password from the customer. We then use the below command to access the MySQL server from console.
mysql -u user -ppassword
Replace user with MySQL username and password with MySQL password.
If the logins work, the next step is to check whether these logins are working for phpMyAdmin. If not, we can make sure that these logins are not updated in the phpMyAdmin configuration.
So, our Database Experts access the phpMyAdmin configuration file and add the correct username and password in the config.inc.php file.
For example, on a local WAMP server, the location of config.inc.php will be C:\wamp\apps\phpmyadminx.x.x. Similarly, on Plesk servers, this location will be /usr/local/psa/admin/htdocs/domains/databases/phpMyAdmin/libraries/config.default.php.
Here, our Support Experts modify the following parameters and ensure that correct username and password is used.
$cfg['Servers'][$i]['user'] = 'root'; //MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password
In some cases, we change auth_type parameter for the logins to work.
$cfg['Servers'][$i]['auth_type'] = 'cookie'
Finally, we clear the browser cookies to refresh the data.
On the other hand, if the MySQL logins doesn’t work, we reset the MySQL user password and update the new one in the phpMyAdmin configuration.
For example, in cPanel servers, we reset the user password from Databases > MySQL Databases > Current Users. Similarly, we reset the MySQL root password after starting the MySQL in safe mode.
UPDATE mysql.user SET Password=PASSWORD("EnterYourPasswordHere") WHERE User="root";
FLUSH PRIVILEGES;
2) Insufficient privileges
Similarly, another common reason for this error is the insufficient privileges for the database user that’s trying to connect to the database. For example, customers receive an error like below.
#1045 - Access denied for user 'user'@'localhost' (using password: YES)
This means that the database user ‘user‘ is not permitted to access the database.
Solution
Now, let’s see what our Support Engineers do in these cases.
Here, we make sure that proper privileges are given for the user to access the database. For example, we assign proper privileges to the database user using the below command.
GRANT ALL PRIVILEGES ON *.* TO user@'localhost' IDENTIFIED BY 'password' with grant option;
This will grant all privileges to the database user ‘user‘ on the selected database. Later, we save these privileges using the below command.
FLUSH PRIVILEGES;
Likewise on cPanel servers, we change the privileges of the user from cPanel > Mysql databases > Current databases > Privileged users > Click on the database user.
[Need an Expert to fix this MySQL error on your server? Click here and get one of our Database Experts to fix it for you.]
Conclusion
In short, phpMyAdmin error 1045 occurs mainly due to typo errors in MySQL username or password, insufficient privileges of the database user and so on. Today, we’ve discussed the top 2 reasons for this error and how our Dedicated Support Engineers fix them.
0 Comments