MySQL Installation / Password Setup - Magento 2.4

I am in the process of installing Magento 2.4 on my server as per the instructions given on How to install Magento 2.4 and build a web server

I am able to setup Apache server post that - and I am able to install MySQL server. Later, when I am trying to switch MySQL password plugin and setup password - I am running in to issues and my password command is not getting executed as desired.

Even though, I am able to install phpMyAdmin - I am not able to login using the root password - which I created using the following command:

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

I am only able to login using phpMyAdmin user name and not the root user name - which I originally created using the command prompt.

My Setup

  1. Shared or Dedicated Server? VPS
  2. Did your setup the server or install Magento yourself? I am trying to setup Magento by myself.
  3. What are your server specifications? 3 GB RAM, Ubuntu 20.4, 3 CPU
  4. What version of Magento are you using? Trying to install Magento 2.4

I tried reinstalling the server a few times and the issue is not going away even though I am starting afresh - I am running in to same issue again.

Any suggestions on how I can possibly rectify the issue? Kindly suggest.

Hi @govileo and welcome

That command you referenced normally works wonders for me. I wonder, when you run mysql_secure_installation are you setting up password strength or disabling it? I’ve had issues with this feature in the past so typically, I’ve got used to simply disabling this when prompted.

I am disabling the password setup after enering mysql_secure_installation - as per the inputs shared in your article.

I am running in to issues - when I am trying to switch Switch MySQL Password Plugin.

Is there a workaround for this step? Kindly suggest.

Another way would be to create a MySQL user with all privileges. Basically, a “superuser”.

You create this in the Command Line Interface.

How to create a superuser for MySQL

Step 1: After accessing the Command Line Interface, access MySQL (as root) with:

mysql -u root -p

Note: Password prompt requires your MySQL root password (not your OS root password).

Step 2: Create a new user (craig) and set a password (XHUWKEGsHKG@cERxKyCX8Lm):

CREATE USER 'craig'@'localhost' IDENTIFIED BY 'XHUWKEGsHKG@cERxKyCX8Lm';

Step 3: Give this new user all privileges:

GRANT ALL PRIVILEGES ON * . * TO 'craig'@'localhost';

Step 4: Flush MySQL privileges for the changes to take affect:

FLUSH PRIVILEGES;

Step 5: Log out of MySQL:

exit

Screenshots

CLI (SSH)
MySQL New

phpMyAdmin

1 Like

Thank you, Craig! I will test this new method as well.

Btw, the issue with MySQL got rectified after ensuring that I copy the command syntax properly.

Initially, I had issues mainly because of the syntax - I was copying from the notepad - and when I tried to paste the command - it did not get copied as desired resulting in an issue while creating the user account.

Thanks again for your help.

1 Like

I’m glad you’re all sorted. Thank you for clarifying the issue :+1:

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