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"
mysqladmin -u root password "NEW-PASSWORD"
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
# mysql -h localhost -u root -p
- -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"
Enter password: <enter old password>
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop