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
LVL 3
piratepatrolAsked:
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.

wesly_chenCommented:
Hi,

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

Wesly
0
paullamhkgCommented:
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';
mysql> FLUSH PRIVILEGES;

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

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
0
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
Linux

From novice to tech pro — start learning today.