No announcement yet.

How to change MySQL root password?


Ads on showthread pages

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change MySQL root password?

    WordPress Hosting on SSD Servers
    How to change MySQL root password?

    How to change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?

    mysqladmin command to change root password

    If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:

    $ mysqladmin -u root password NEWPASSWORD

    However, if you want to change (or update) a root password, then you need to use following command

    $ mysqladmin -u root -p oldpassword newpass

    Enter password:

    Change MySQL password for other user

    To change a normal user password you need to type (let us assume you would like to change password for ryan):

    $ mysqladmin -u ryan -p oldpassword newpass

  • #2
    ASP.Net Hosting starts @ $3.18/Mo.
    Re: How to change MySQL root password?

    I ran into this the other day and I had to do a little quick fix .... I found this on the net somewhere

    shell> kill `cat /mysql-data-directory/`
    shell> mysqladmin -u root password 'mynewpassword'
    shell> mysqladmin -h hostname flush-privileges

    Alternatively, you can set the new password using the mysql client:

    1. Take down and restart mysqld with the --skip-grant-tables option as described above.
    2. Connect to the mysqld server with: shell> mysql -u root mysql
    3. Issue the following commands in the mysql client:
    mysql> UPDATE user SET Password=PASSWORD('mynewpassword') -> WHERE User='root';
    4. mysql> FLUSH PRIVILEGES;

    After this, you should be able to connect using the new password. You can now stop mysqld and restart it normally.


    Sign up for a News Letter Click here to sign up