mysqladmin Change User Password

Summary: in this tutorial, you will learn how to use the mysqladmin to change the user password.

mysqladmin is a client tool that allows you to perform common administrative tasks. You can use the mysqladmin to change the password for a user.

Here’s the basic syntax of setting a new password for a user using the mysqladmin command:

mysqladmin [options] passwordCode language: SQL (Structured Query Language) (sql)

In this syntax:

  • mysqladmin: Invoke the mysqladmin program.
  • [options]: Specify the connection details including hostname, port, user, and password.
  • password: Instruct mysqladmin to change the password for the user that you use to connect to the MySQL server.

The mysqladmin will change the password for the user that you use to connect to the MySQL server.

We’ll demonstrate how to change the password for the user account bob on the local MySQL server.

First, open the Command Prompt on Windows or the Terminal on Linux.

Second, change the password for the user bob using the mysqladmin tool:

mysqladmin -u bob -p passwordCode language: SQL (Structured Query Language) (sql)

It’ll prompt you to enter the current password for the user account bob:

Enter password: ********Code language: SQL (Structured Query Language) (sql)

If you enter a valid password, the mysql admin will prompt you to enter the new password for the user account bob twice:

New password: *********
Confirm new password: *********Code language: SQL (Structured Query Language) (sql)

If both passwords are matched and follow the password policy set by the MySQL server, the mysqladmin will change the password for the user account bob.

When you use the user account bob to connect to the MySQL server next time, you need to provide the new password.

Security concern

Note that mysqladmin will also issue the following warning:

Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.Code language: SQL (Structured Query Language) (sql)

The warning alerts you that when you use mysqladmin to change the user’s password, mysqladmin transmits the password in plain text over the network to the MySQL server.

This can pose a security risk because if someone can capture the traffic between your computer and the MySQL server, they will know your password.

To address this concern, the warning suggests that you use an SSL connection to ensure the safety of the password during the transmission. The SSL encrypts the data exchanged between your computer and the MySQL server, protecting it from potential interception.

Summary

  • Use mysqladmin [options] password command to change the password for a user account.
Was this tutorial helpful?