# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password ‘new-password’
To change a user’s password in MySQL from the MySQL prompt while logged in as the root user, you can use the following steps:
- To change a MySQL user’s password from the Unix shell, you can use the
mysqladmin
command. Here’s an example:bashmysqladmin -u <username> -p password <new_password>
Replace
<username>
with the actual username for which you want to change the password, and<new_password>
with the desired new password. You will be prompted to enter the current password for the specified MySQL user.Alternatively, you can use the
mysql
command to achieve the same result:bashmysql -u <username> -p -e "ALTER USER '<username>'@'localhost' IDENTIFIED BY '<new_password>';"
Again, replace
<username>
with the actual username and<new_password>
with the desired new password. You will be prompted to enter the current password for the specified MySQL user.Note: Ensure that you have the necessary privileges to modify the password for the