Changing mySQL root password

Here, we assume that the root password of mySQL is known. This tutorial has nothing to do with resetting forgotten root password. If we already know the root password of a mySQL database, here's how it can be changed -


mysqladmin -u root -pcurrentpassword password 'newpassword'

keep in mind that there is no space after the -p parameter.

Hope this helps. ^_^

Comments

  1. To reset forgotten password in Debian, it is quite easy as long as you can run sudo(8) or as root. No, there is not a security issue, as if your machine has been cracked and the root password are out there, you got bigger problems.

    But security wise you should always avoid to enter passwords on the command line, as that will end up in history and show up in ps(1) listings. Just using the password without a new password will get you a prompt where you enter the new password.

    But, here is how you can run mysqladmin(1) without needing to set user or password.

    sudo mysqladmin --defaults-file=/etc/mysql/debian.cnf proc stat

    The contents of that file are needed for mysql to work as it should. Read documentation at /usr/share/doc/mysql-server-5-5/README.Debian.gz for more information about this file and its contents. But of course, you have already read that one, haven't you? ;-)

    ReplyDelete

Post a Comment