Jump to content
Sign in to follow this  
alan

How to reset mysql root password

Recommended Posts

try this

 

./mysqladmin -u root password new-password

 

cheers

 

anyweb

Share this post


Link to post
Share on other sites

I had the same problems but was getting some funny error messages with anywebs command so I used this reference :

 

http://dev.mysql.com/doc/mysql/en/Resetting_permissions.html

 

Its was really good however where it says this:

 

shell> kill `cat /mysql-data-directory/host_name.pid`

 

I did this:

 

kill cat '/urs/local/mydsql/data/linux.domain.com.pid'

 

to get the process id to stop mysql. The rest worked fine and was a great help.

Share this post


Link to post
Share on other sites

Never forgotten a password, then you must be in the minority. All is not lost however there is a way of starting MySQL and then accessing it without a password.

 

# /etc/init.d/mysql stop
# killall mysqld
# mysqld --skip-grant-tables --user=root &
# mysql
mysql> use mysql;
mysql> update user set password=password("newpassword") where user="root";
mysql> flush privileges;
mysql> exit
# killall mysqld
# /etc/init.d/mysql start

 

Thats it.. a quick and easy way to recover your mysql database password happy.gif

Share this post


Link to post
Share on other sites

pinned

 

thanks znx !

Share this post


Link to post
Share on other sites

Some more notes..

 

If you see this complaint:

# mysqld --skip-grant-tables --user=root &
# 060318 16:31:10 [Warning] Ignoring user change to 'root' because the user was set to 'mysql' earlier on the command line

 

Then its most likely still running, you can confirm with:

# netstat -tlp | grep mysql
tcp  0  0  host.domain:mysql  *:*  LISTEN  20310/mysqld
# killall mysqld
# netstat -tlp | grep mysql
#

 

And then you can continue to the next step...

Share this post


Link to post
Share on other sites

If you find that you can't execute mysqld .. then it could be that the mysql server is hidden, so you can use:

 

/usr/libexec/mysqld --skip-grant-tables --user=root &

 

Instead :D

Share this post


Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...