Monday, May 25, 2009

Reset MySQL 5 password

I am running a Joomla training this week. One of the main items is getting the password assignment for root and database user. As a reference here is to resetting root password and assigning user to have full access to a database.

Reset root password
Step 1: Restart the MySQL server without using the user restrictions and access to the network.

#/etc/init.d/mysql stop
#mysqld --skip-grant-tables --skip-networking&

Step 2: Open another terminal and reset your password

# mysql mysql -u root
mysql> UPDATE user SET password=PASSWORD('NewPassword') WHERE user="root";
mysql> FLUSH PRIVILEGES;
# /etc/init.d/mysql restart

Assigning user access to database
Step 1: Login a root to mysql


Step 2: Assign the user joe to use from localhost the database somedatabase.
mysql> GRANT ALL privileges ON somedatabse.* TO joe@localhost IDENTIFIED BY 'SomePassword';
mysql> FLUSH PRIVILEGES;

No comments:

Blog Archive