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

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...
Apache 2 + MySQL 5 + PHP 5.3 + phpMyAdmin 3.5.4 installation script for Mac OS X using MacPorts
Based on the instructions provided by Gilles Fabio I've created a complete installation script to install...
Useful Apache 2 and MySQL 5 service aliases for MacPorts
Those are some aliases I use to start, stop and restart Apache 2 and MySQL on my MacPorts installation...
Make Raspbian run from an external USB hard drive or USB memory stick
Raspberry Pi can ONLY boot from the SD Card. If you want to use your Raspberry Pi from an external USB...
Leave a comment ?

1 Comments.

  1. Perfecto!!!

    Reply

Leave a Comment