Change MySQL Password on Ubuntu – dpkg-reconfigure mysql-server-5.1

Forgot MySQL server root password? It’s trivial to change it in Ubuntu and Debian.

sudo dpkg-reconfigure mysql-server-5.1

To get the version of your package, just type ‘sudo dpkg-reconfigure mysql-server-5″ and press tab a couple of times.

It simply asks for new MySQL root password. Accept the default answer to any other question by pressing enter.

Choosing Password

Select a good password. It must be different from any password already used in your system, because MySQL has it’s own user system, separate from Linux users. For example, MySQL “root” is completely unrelated to the user that can install software in Linux.

Log in with Your New Password

Now you can log in with PhpMyAdmin (http://localhost/phpmyadmin) or command line client

$ mysql -u root -p

Solved Errors

By changing the password, you solve these common errors: “#1045 Cannot log in to the MySQL server”, “ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: YES)”.

Administrivia

Tested succesfully in Ubuntu 10.04 LTS lucid, 11.10 and Ubuntu 12.04 alpha1.

Update: Verified (again) on Ubuntu 10.04 LTS lucid (mysql-server-5.1 5.1.41-3ubuntu12.6, apt 0.7.25.3ubuntu7, dpkg 1.15.5.6ubuntu4) that my databases are intact after this, only root password changes.

Briefly in Finnish: Unohtunut MySQL-palvelimen salasana on helppo vaihtaa.

Posted in Uncategorized | Tagged , , , , , , , , , | 2 Comments

2 Responses to Change MySQL Password on Ubuntu – dpkg-reconfigure mysql-server-5.1

  1. Anvesh says:

    Nice Article !
    I have also worked around this and found that one more step is require in some condition. Kill to old mysqld process.
    I have also preapred my own step, please visit my blog:
    http://www.dbrnd.com/2015/08/reset-mysql-root-password-ubuntu/

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Picks

  • Boxing Clock for AndroidOcton8 Diving T-ShirtsShaking Tower Panda Android GameLearn Chinese with Android
  • Student projects