The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Lost root password - how to reset?

Hi. I've lost my root password.

I'm using Mac OS X 10.2.5. I had a 3.x install of MySQL, and decided to update to 4.0.12 using the Mac OS X installer package from mysql.com.

Unfortunately, I forgot the root password I originally used, and it seems to be persistant. I've deleted the previous mysql installation files, but that didn't seem to make any difference. I've deleted the mysql user using NetInfo manager but that didn't seem to make any difference. I deleted the mysql user AND the new MySQL install and reinstalled. No difference.

In addition now when I try to start mysql I get
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I don't know enough about this to even know where to start debugging the problem.

What I would really like is to know how to completely remove MySQL and all related files and do a clean install. I would settle for being able to reset my root password (or passwords -- the searches I've done on this forum seem to imply there may be two).

I have no existing databases to fear losing. I just want to work through the MySQL/PHP book I bought from SitePoint, and I can't move forward without knowing/resetting the mysql root password(s).

Yes, I tried that page before I posted here. I'm on a Mac, FreeBSD-based Darwin. Those instructions appear not to apply.

Here's the breakdown:

>Question :
>I have lost my MySQL root password, how can I get in?
>Answer :
>If you have forgotten the root user password for MySQL, you can
>restore it with the following procedure:
>
>Take down the mysqld server by sending a kill (not kill -9) to the
>mysqld server.

Already not running.

>The pid is stored in a .pid file, which is normally in the MySQL
>database directory:
>kill `cat /mysql-data-directory/hostname.pid`

No such file as "hostname.pid". Stike one.

>You must be either the Unix root user or the same user the server
>runs as to do this.

Being unable to launch mysql pretty much negates the whole of the rest of the advice below.

Strike three, I'm out.

I've spent a couple of hours trying to figure out how to solve the /tmp/mysql.sock problem, but my sock puppet skills are not l33t.

So until I figure out the sock problem, I can't figure out the root problem. I'm starting to feel like a badly-dressed gardener. Or a cross between the Beasties and the Chili Peppers.

And that's why I wish I could go back to square one and do a clean install.

>Connect to the mysqld server with mysql -h hostname mysql and
>change the password with a GRANT command.
>
>See section 7.35 GRANT and REVOKE Syntax
>http://www.mysql.com/doc/G/R/GRANT.html
>
>You can also do this with mysqladmin -h hostname -u user
>password 'new password'
>
>Load the privilege tables with: mysqladmin -h hostname
>flush-privileges or with the SQL command FLUSH PRIVILEGES.
>
>Note that after you started mysqld with --skip-grant-tables, any
>usage of GRANT commands will give you an Unknown command error
>until you have executed FLUSH PRIVILEGES.