I Can't Access MySQL Anymore - Please Help

Hi friends,

I fooled around with the user table in the mysql database.  I ran the following command just for kicks:

update user set password='boo';

After I restarting my computer, I can no longer access mysql.  The error message is

ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

FYI, before I fooled around with the user table, I was able to connect to MySQL via PHP with the username "root" and no password.

Please kindly help me resolve this issue.  I don't know where to start.  I'm a Linux newbie.  You folks are so awesome.

Jazon from Jacksonville, FL
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


1. # mysql -u root -h localhost -p"
and do not give any password press enter.
2. edit /etc/my.cnf
3. # mysqladmin -u root password <new password>
for setting password
4. # mysqladmin -u root -p password <new password>
enter password: <old password>

for resetting the root password is as follows:

Log on to your system as either the Unix root user or as the same user that the mysqld server runs as.
Locate the `.pid' file that contains the server's process ID. The exact location and name of this file depend on your distribution, hostname, and configuration. Common locations are `/var/lib/mysql/', `/var/run/mysqld/', and `/usr/local/mysql/data/'. Generally, the filename has the extension of `.pid' and begins with either `mysqld' or your system's hostname. Now you can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the pathname of the `.pid' file in the following command: shell> kill `cat /mysql-data-directory/host_name.pid`

Note the use of backticks rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.
Restart the MySQL server with the special --skip-grant-tables option: shell> mysqld_safe --skip-grant-tables &

Set a new password for the root@localhost MySQL account: shell> mysqladmin -u root flush-privileges password "newpwd"

Replace ``newpwd'' with the actual root password that you want to use.
You should now be able to connect using the new password.
Alternatively, on any platform, you can set the new password using the mysql client:

Stop mysqld and restart it with the --skip-grant-tables option as described earlier.
Connect to the mysqld server with this command: shell> mysql -u root

Issue the following statements in the mysql client: mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd')
    ->                   WHERE User='root';

Replace ``newpwd'' with the actual root password that you want to use.
You should now be able to connect using the new password.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
piratepatrolAuthor Commented:
Hey guys,

I just went ahead and formatted the harddrive and installed Fedora 2 again.  Thanks for your help anyway.  I split the point between you guys.

Thanks a bunch,

Jazon from Jacksonville, FL
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.