Change root password in MySQL

In GNU/Linux:

$ sudo mysqld_safe --skip-grant-tables &
$ mysql -u root -p
#press enter to use a blank password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit;
$ sudo service mysql stop
$ sudo service mysql start
#try your new password
$ mysql -u root -p

In Mac OS X with MySQL installed with MacPorts:

$ sudo /opt/local/lib/mysql5/bin/mysqld_safe --skip-grant-tables &
$ mysql -u root -p
#press enter to use a blank password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit;
$ sudo port unload mysql5
$ sudo port load mysql5
#try your new password
$ mysql -u root -p

You might also like

View MySQL server information
With the server up and running:$ mysqladmin variables -u root -p Enter password: +----------------------------+----------------------------+ |...

Can’t change user options in MySQL Administrator
May be you installed MySQL 5 and you are not able to change user information, schema privileges and resources...

Can’t change user options in MySQL Administrator
May be you installed MySQL 5 and you are not able to change user information, schema privileges and resources...

Fix ERROR 2006 (HY000) at line ###: MySQL server has gone away
I once had a project with one MySQL table that had over 2 million rows. First time I tried moving that...

  1. Perfecto!!!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.