Change MySQL root password
Q. How do I change MySQL server root password under Linux / UNIX operating system at shell prompt?
A. You need to mysqladmin command which is a client for performing administrative operations. You can use it to check the server’s configuration and current status, to create and drop databases, change mysql root password and more.
How do I change mysql root password?
If you are setting a root password first time, use any one of the following command syntax:
mysqladmin password "NEW-PASSWORD"
OR
mysqladmin -u root password "NEW-PASSWORD"
OR
mysqladmin -u root -h localhost password "NEW-PASSWORD"
To set password to d3s9cXq, enter:
# mysqladmin -u root password "d3s9cXq"
Please note that if the NEW-PASSWORD value contains spaces or other characters that are special to your command interpreter, you need to enclose it within quotes. Thus, the next time you invoke mysqladmin (or any other client program such as mysql) using the same account, you will need to specify the new password. So to login as root, enter the command:
# mysql -u root -p
OR
# mysql -h localhost -u root -p
Where,
- -u root: Specify username
- -p : Prompt for password
If you would like to change current password d3s9cXq to OlzzYs$qz, enter the following command:
# mysqladmin -u root -p password "OlzzYs$qz"
Output:
Enter password: <enter old password>
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- MySQL change root password
- Mysql user creation - setting up a MySQL new user account
- What is My root Password for MySQL Database Server?
- What is my root password for MySQL?
- How do I access MySQL server from the shell prompt (command line)?
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: mysqladmin_command, mysql_change_root_password, mysql_server, root_password ~ Last updated on: September 27, 2007



May 10th, 2008 (3 days ago) at 2:29 pm
Where do you type those commands??
May 10th, 2008 (3 days ago) at 2:43 pm
At a shell prompt.