Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-28-2009, 10:00 AM   #1
Registered: Sep 2008
Posts: 90

Rep: Reputation: 15
Lost MySQL password

Ok, I managed to mess something up and I forgot or made a wrong entry somewhere for my MySQL password.

How can I uninstall MySQL and re-install a fresh copy?

I have tried this but got an error:
[root@localhost /]# rpm -e mysql
error: Failed dependencies:
        mysql = 5.0.67-2.fc10 is needed by (installed) mysql-server-5.0.67-2.fc10.i386
        mysql is needed by (installed) MySQL-python-1.2.2-7.fc10.i386

rpm -qa | grep -i mysql


rpm -e

in some order

I uninstalled mysql and installed it again however when I try to login:

[root@localhost /]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost /]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Last edited by JavaNinja; 01-28-2009 at 10:13 AM.
Old 01-28-2009, 11:41 AM   #2
Registered: Dec 2003
Location: Calgary, AB
Distribution: Any!
Posts: 146

Rep: Reputation: 18
I've used this method to reset some lost root passwords:

Step 2 can be replaced with

/etc/init.d/mysqld stop
Or whatever the init script is called.

Hope that helps.
Old 01-28-2009, 12:29 PM   #3
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Just incase you are having one that I have had before, sometimes on very brand new installs of MySQL their might not be any accounts at all! you have to start MySQL in a rescue/maintainance mode and actually create a brand new root account... unfortantly I don't have time right now to look up the link for that one that I had to use, it was on the official MySQL site tho.
Old 01-28-2009, 02:40 PM   #4
Registered: Sep 2008
Posts: 90

Original Poster
Rep: Reputation: 15

When you uninstall make sure you also remove any files left otherwise you will never have a fresh install of mysql.

I hope the above saves somebody a few hours of headache.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost mysql root password on slack server iiKster Slackware 6 12-29-2008 05:30 PM
Lost of mysql root password satimis Linux - Server 6 12-06-2007 09:05 PM
mysql root password lost nazir Linux - Software 6 10-09-2007 10:18 AM
lost mysql password, can't recover slackhack Linux - Software 1 12-03-2005 05:15 PM
Mysql Error: Lost Connection to Mysql during query ramnath Programming 5 11-18-2003 12:27 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration