How to Change MySQL Root User Password Ubuntu 22.04|20.04

How to Change MySQL Root User Password Ubuntu 22.04|20.04

If you want to change the password of the root user of MySQL in your Ubuntu system, you have to type 3 commands such as sudo mysql, use mysql, AND UPDATE USER SET authentication_string = password(“new_password”) WHERE user = “root”, on the command line.

Through this tutorial, we will show you how to change the Mysql user or root user password on Linux ubuntu using the command line.

How to Reset or Change MySQL Root User Password on Linux ubuntu

Here are some steps for changing or resting the MySQL root user password on Linux ubuntu using the command line:

Step 1 – Login to the MySQL shell as root

First of all open the command line and execute the following command into the command line to access the MySQL root user:

mysql -u root -p

Step 2 – Change the MySQL Root user password

Execute the following commands on the command line or terminal to change MySQL 8.0 user password on the Linux Ubuntu system:

UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;

Replace new_password with your own password:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';

Step 3 – Restart MySQL Server

Execute the following command on the command line or terminal to restart start MySQL server:

sudo systemctl restart mysql

Step 4 – Verify the new password

Execute the following command on the command line to verify that the new password has been applied correctly type:

Login to MySQL using the new password.

sudo mysql -u root -p

Enter the new password you set before when prompted.

Here is the video guide on how to change MySQL root user password on ubuntu using command line:

Conclusion

Through this tutorial, you have learned how to change or reset the Mysql user password on Linux Ubuntu 22.04 using the command line.

Recommended Linux Ubuntu Tutorials

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *