Introduction
Fixing “access denied for user root” in CyberPanel? This mysql root access denied error and phpMyAdmin blank pages are common. Follow our simple guide to reset mysql password cyberpanel while your websites stay live.
Problem
Before we dive into the solution, let’s confirm the problem. You’re likely experiencing one or more of these symptoms:
- phpMyAdmin is Inaccessible: You try to access phpMyAdmin from your CyberPanel dashboard, but it only loads a blank, white page.
- SSH Login Fails: When you try to log into MySQL as the root user via SSH (with or without a password), you are greeted with the error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) - Websites are Unaffected: Crucially, your MySQL server is still running, and all your websites and web applications continue to function normally. This confirms the service is up, but authentication for the root user is broken.
Resolution
NOTE: These steps require root SSH access to your server.
Step 1: Stop the MySQL Service
Connect to your server via SSH as the root user. The first step is to stop the database service to perform the password reset.
systemctl stop mariadb
Step 2: Create the Initialization File
We will create a special file that MariaDB will read upon startup to reset the root password.
touch /var/lib/mysql/mysql-init
Now, open this file with a text editor like vi or nano and add the following line. Pro Tip: To maintain consistency, use the same password that is stored in your /root/.my.cnf file.
# Check the current password in .my.cnf cat /root/.my.cnf # Then, edit the init file and use that password vi /var/lib/mysql/mysql-init
Add this line to the file (replace "supersafepassword" with your actual password):
ALTER USER 'root'@'localhost' IDENTIFIED BY 'supersafepassword';
Step 3: Set Correct File Permissions
Ensure the MySQL user can read this file by changing its ownership.
chown -v mysql. /var/lib/mysql/mysql-init
You should see a confirmation message:
changed ownership of '/var/lib/mysql/mysql-init' from root:root to mysql:mysql
Step 4: Start MySQL with the Init File
Now, start MySQL manually and tell it to execute the commands in your initialization file.
mysqld -u mysql --init-file=/var/lib/mysql/mysql-init &
You will see a series of startup logs ending with ...
Look for the line
mysqld: ready for connections.
This indicates the server has started and your root password has been reset.
Step 5: Shutdown MariaDB Safely
Once the password is updated, stop the manually started MariaDB instance properly.
mysqladmin -u root shutdown
Step 6: Clean Up and Restart
For security and cleanliness, remove the initialization file and then restart the MySQL/MariaDB service normally.
/bin/rm -vi /var/lib/mysql/mysql-init systemctl start mariadb
Step 7: Verify the Fix
Finally, check that the service is running and test your new root password.
systemctl status mariadb mysql -u root -p
Conclusion
Congratulations! You have successfully reset the MySQL/MariaDB root password on your CyberPanel server. You should now be able to log into phpMyAdmin without a blank page and access MySQL via SSH without the “Access Denied” error. Your database service is now running securely with the new credentials. Bookmark this guide for future reference, and as always, remember to keep your passwords safe and secure.

