Control Web Panel

WebPanel => MySQL => Topic started by: Wonder on October 26, 2025, 10:11:03 PM

Title: MariaDB Password Reset Script Doesn't Work
Post by: Wonder on October 26, 2025, 10:11:03 PM
I know this script worked perfectly before.
Code: [Select]
/scripts/mysql_pwd_reset
I've recently done several installations of CWP 8 (for various tests), and after installing CWP 8 without restarting, if we run the password reset script, it works. However, if we restart CWP 8 after installing it, it no longer works, and from what I can see, we lose access to CWP administration (and therefore, the MariaDB service is inoperative).
I've tested it with both the stock and upgraded versions of MariaDB.

I understand that, over time and with updates, the script has become "outdated."

This is the code that appears when we run it:

Code: [Select]
[root@server ~]# /scripts/mysql_pwd_reset

Enter the new root password (at least 8 chars).
Or leave it empty if you would like to generate it.
Or press CTRL+C to abort and do not touch it

Enter MySQL root password (NO special characters): testpass9876
Shutting down any mysql processes...
/scripts/mysql_pwd_reset: line 14: [: -eq: unary operator expected
Redirecting to /bin/systemctl stop mariadb.service
/scripts/mysql_pwd_reset: line 26: [: -eq: unary operator expected
Redirecting to /bin/systemctl start mariadb.service
Resetting password... hold on
--------------
UPDATE mysql.user SET Password=PASSWORD('testpass9876'),Authentication_string=PASSWORD('testpass9876') WHERE user='root'
--------------

ERROR 1348 (HY000) at line 1: Column 'Password' is not updatable
Cleaning up...
/scripts/mysql_pwd_reset: line 14: [: -eq: unary operator expected
Redirecting to /bin/systemctl stop mariadb.service

Password reset has been completed

New MySQL root password: testpass9876

Remember to store this password safely!

/scripts/mysql_pwd_reset: line 26: [: -eq: unary operator expected
Redirecting to /bin/systemctl start mariadb.service
[root@server ~]#
Title: Re: MariaDB Password Reset Script Doesn't Work
Post by: overseer on October 26, 2025, 11:30:08 PM
Yes, that script is defunct. Use this instead:
https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password
Title: Re: MariaDB Password Reset Script Doesn't Work
Post by: cyberspace on October 29, 2025, 09:35:29 AM
Try following:

1. Edit the file:
/scripts/mysql_pwd_reset
2. Find and change the line:
Code: [Select]
EL_VER=`rpm -qa \*-release | grep -Ei "oracle|redhat|centos|cloudlinux" | cut -d"-" -f3`to
Code: [Select]
EL_VER=`rpm -qa \*-release | grep -Ei "oracle|redhat|centos|cloudlinux|epel"| head -n 1 | cut -d"-" -f3`
then run the script /scripts/mysql_pwd_reset to change the password.