- Change a Password for MySQL on Linux via Command Line
- Create a MySQL Database on Linux via Command Line
- MySQL Select Database on Linux Via Command Line
- How to Backup a MySQL Database: Complete Guide
- Delete a MySQL or MariaDB Database via Command Line
Data security is essential to developers, business owners, and system administrators. A vital element of securing data is password management. This guide will teach you how to change a MySQL password in Linux using the command line.
- A server running CentOS or AlmaLinux.
- Root-level access to the server.
How to Change a MySQL Password on Linux via Command Line
Log into the MySQL server from the command line with the following command.
mysql -u root -p
This command specifies the root user with the -u flag, and the -p flag is for MySQL to prompt for a password. Enter your current password to complete the login.
Switch to the appropriate MySQL database with the following command.
Next, update the password for all MySQL users with the name root. Replace your_new_password with your new password. You can change the password for any user with this command by specifying the username in place of the word root.
update user set password=PASSWORD('your_new_password') where User='root';
Finally, reload the privileges with the following command.
Once all steps are completed, exit MySQL.
Completing the MySQL password change in the Linux command line helps administrators manage passwords effectively. Mitigating the risk of security breaches by managing passwords adds yet another layer of security to your arsenal.
- Using MySQL Command Line to Create a User
- How to Use Disk Quotas in Dedicated Linux Servers With cPanel
- How to Use Disk Quotas in Dedicated Linux Servers with Plesk
- Remove a MySQL User on Linux via Command Line
- Remove Permissions for a MySQL User on Linux via Command Line
- Grant Permissions to a MySQL User on Linux via Command Line
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.