MySQL Change Root Password

When you first install mysql, there won’t be a mysql password set for you. In order to set a mysql root password, you can use the mysqladmin command.

Create MySQL Root Password

Firstly change to the folder where your mysql is installed and enter the following command, where mypassword is the new password to use for mysql.

mysqladmin -u root password 'mypassword'

Update MySQL Root Password

If you already set a root password for mysql and would like to update it, you can use the following command where oldpass is your original password and newpass is the new root password to use for mysql.

mysqladmin -u root -p 'oldpass' password 'newpass'

Change Password For Other MySQL Users

You will notice that the above two commands we specify the username as root. What this means is that we can use the same commands to change a mysql password for other users. Use the following command where someuser is the mysql username you want to change the password for, oldpass is your original password and newpass is the new password for that mysql user.

mysqladmin -u someuser -p 'oldpass' password 'newpass'

One Response to MySQL Change Root Password

  1. [...] start Now, you should have your new MySQL root password! I recommend you write it down this time! Background: Sometimes a system administrator forgets the MySQL root password! It happens, but what t…> or service mysql stop Step 2: Start the MySQL Server mysqld_safe –skip-grant-tables & We do this [...]

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>