WARNING : Requires mysql restart for Steps 1-3
This can be done without...
Once you login to the Linux Box, in order to create a temporary root for yourself with the password t3mpp@assw0rd
, perform the following steps
STEP 01) service mysql restart --skip-networking --skip-grant-tables
STEP 02) At Linux prompt, type mysql
and hit enter
STEP 03) Run this SQL Command
SELECT COUNT(1) RootLocalhostExists FROM mysql.user
WHERE user='root' AND host='localhost';
- If
RootLocalhostExists
is 0, stop here. Leave a comment in my answer.
- If
RootLocalhostExists
is 1, go on to STEP 04.
STEP 04) Perform these SQL commands
CREATE TABLE mysql.user2 LIKE mysql.user;
INSERT INTO mysql.user2 SELECT * FROM mysql.user
WHERE user='root' AND host='localhost';
UPDATE mysql.user SET PASSWORD=PASSWORD('t3mpp@assw0rd')
WHERE user='root' AND host='localhost';
STEP 05) service mysql restart
That will do your steps 1-3.
PASSWORD RESTORATION
To put back the original mysql root, do this (MySQL Restart Not Needed):
STEP 01) At Linux prompt, type mysql -uroot -pt3mpp@assw0rd
and hit enter
STEP 02) Execute the Following SQL
DELETE FROM mysql.user WHERE user='root' AND host='localhost';
INSERT INTO mysql.user SELECT * FROM mysql.user2;
DROP TABLE mysql.user2;
FLUSH PRIVILEGES;
EXIT
That's it.
Give it a Try !!!