Reset user password in MySQL

Senior Software Engineer
Search for a command to run...

Senior Software Engineer
No comments yet. Be the first to comment.
Updating the Node.js version in a PM2-managed application requires a few key steps to ensure a smooth transition without losing your process state. Follow these steps to update Node.js while keeping your PM2 processes intact. Step 1: Save the Current...

Are you facing the below error when installing the vmware modules in Vmware workstation? I followed the instructions to install those modules from this GitHub repo. Find the vmware version installed To find version of the vmware installed, run th...

You can secure access to private or protected sites in HAProxy by enabling basic authentication, which prompts users for a username and password. Steps for Setting Up Basic Authentication: Create User Details: In /etc/haproxy/haproxy.cfg, add the us...

Let's see how to reset the MySQL user password.
I am using the below commands to reset the MySQL root user password in the Ubuntu 22 LTS.
sudo systemctl stop mysql
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
If you face the error like below,
mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists
Then run the below commands, to create and folder and update the permission
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
Use the below command to login, without password
mysql -u root
Change the databse to mysql, by usnig the below command
use mysql;
Flush the privileges
FLUSH PRIVILEGES;
Try to alter the password, by using the command
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
If you face the below error
ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded
Then, update the Plugin for authentication
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
Exit from mysql
exit
sudo systemctl stop mysql
sudo systemctl start mysql
And, try to login into mysql now with new password you set
mysql -u root -p
Hope it will prompt for password, Enter the password
password: