hey guys, I was just trying an update of our cPanel image and ran into some SQL issues. I managed to fix it by hand but wanted to share the problem and solution here in case anyone needs it. We'll do some further digging on our end to see if this is a result of our install script, or something we should escalate.
The problem:
I couldn't create a new user account. It'd show me the error:
The system failed to connect to the “MySQL” database “mysql” because of an error: ER_ACCESS_DENIED_ERROR (Access denied for user 'root'@'localhost' (using password: YES)) at /usr/local/cpanel/Whostmgr/Accounts/Create.pm line 1197.
First attempt to fix it:
I then proceeded to generate a new root SQL password in WHM. It mentioned it failed and then forcibly created a new SQL password. The new password was not updated in /root/.my.cnf and I was still getting errors. mysql -u root -p also generated an error.
The actual fix:
Long story short, I set a new password by hand. If you have this problem perform the steps below through command-line. Please note this was done on CentOS 7 and the steps may differ per installation (do these steps quickly as it reduces your security until you finally start mysqld again):
1) systemctl stop mysqld
2) systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
3) systemctl start mysqld
4) mysql -u root
5) UPDATE mysql.user SET authentication_string = PASSWORD('yournewpass') WHERE User = 'root' AND Host = 'localhost';
6) FLUSH PRIVILEGES;
7) quit
8) systemctl stop mysqld
9) systemctl unset-environment MYSQLD_OPTS
10) vi or nano /root/.my.cnf and adjust the passwords to your new pass
11) systemctl start mysqld
12) test your pass: mysql -u root -p
The problem:
I couldn't create a new user account. It'd show me the error:
The system failed to connect to the “MySQL” database “mysql” because of an error: ER_ACCESS_DENIED_ERROR (Access denied for user 'root'@'localhost' (using password: YES)) at /usr/local/cpanel/Whostmgr/Accounts/Create.pm line 1197.
First attempt to fix it:
I then proceeded to generate a new root SQL password in WHM. It mentioned it failed and then forcibly created a new SQL password. The new password was not updated in /root/.my.cnf and I was still getting errors. mysql -u root -p also generated an error.
The actual fix:
Long story short, I set a new password by hand. If you have this problem perform the steps below through command-line. Please note this was done on CentOS 7 and the steps may differ per installation (do these steps quickly as it reduces your security until you finally start mysqld again):
1) systemctl stop mysqld
2) systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
3) systemctl start mysqld
4) mysql -u root
5) UPDATE mysql.user SET authentication_string = PASSWORD('yournewpass') WHERE User = 'root' AND Host = 'localhost';
6) FLUSH PRIVILEGES;
7) quit
8) systemctl stop mysqld
9) systemctl unset-environment MYSQLD_OPTS
10) vi or nano /root/.my.cnf and adjust the passwords to your new pass
11) systemctl start mysqld
12) test your pass: mysql -u root -p