MySQL Password Plugin Installation / Root Password Setup Failed - Magento 2.4.5-p1

Hi Everyone.

Happy 2024, I am trying to build a new web server with Magento 2.4.5-p1 following the topic How to install Magento 2.4.5-p1 and build a web server (updated) however, I got an error issue during setup a root password for MYSQL 8 using command

sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlsecupassword'"

sudo mysql UNINSTALL COMPONENT 'file://component_validate_password';

sudo mysql_secure_installation

I got an Error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

It seems that root password for MYSQL 8 can not be written on server or just blank, ensure that password is the same like setup script, but I can use phpMyAdmin username and password login phpMyAdmin, and that is not root user of MYSQL, so that we can not get all privileges.

  • Server OS: Ubuntu 22.04 LTS & update & upgrade
  • Apache 2.4
  • PHP VERSION: 8.1

Login MYSQL 8 succeed after installed sudo apt install mysql-server -y via root user of server or superuser which I created.

But it is not able to login again once setup MYSQL Secure root password

What we tried & fixed:
sudo mysql -u root ( got access denied)
sudo mysql -u root -p (enter password access denied)
remove MYSQL 8 & reinstalled (the same issues access MYSQL denied)

Do you guys having this same issues? I am doing a lot of research online but not a good solution.

Thank you.

I am doing some research online from official site of MYSQL that I’ve got some information about native password install for root user > MySQL 8.0.34 no longer available

As of MySQL 8.0.34, the mysql_native_password authentication plugin is deprecated and subject to removal in a future version of MySQL.

Shall we replace command line:

sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlsecupassword'"


sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'mysqlsecupassword'"

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.