MySQL Forums
Forum List  »  Newbie

Re: any cheat-sheet style documents?
Posted by: Phil Howard
Date: February 10, 2011 11:50AM

No, I don't mean that. I mean something more like the hints in http://www.artfulsoftware.com/infotree/mysqltips.php but with a more thorough coverage of administrator stuff to begin with.

We're putting our documents in a wiki locally. Here's my starting wiki page using the reset 'root' password article from the above link. This is in "wiki edit" form, but will show badly formatted in this forum. Sorry, our internal wiki is not accessible by the public for you to see it formatted. The intent is to add on to this page. The next articles (once I extract the necessary steps from the manual) is "Restore the root user" and/or "Restore lost root privileges".

='''Reset a lost or forgotten root password'''=
First, you need to cleanly shut down the server if it is currently running. Since the loss of password may also affect the system init script's access, send a SIGTERM signal to the process instead of running the service command. The killall command provides an easy way to do this without having to lookup the process ID. It will shut down all MySQL servers on the host this is done on:
killall -TERM /usr/sbin/mysqld

Now run the server without accessing the grant tables. WARNING: Your server is VERY insecure at this time (worse if the server can be reached from the internet). Anyone who can connect can do anything or take over. It will also run in the foreground, so for commands after this, you need to open another shell:
/usr/sbin/mysqld --skip-grant-tables

Now (in a new shell) run the mysql client command:
mysql

The client command connects to the server as usual, but no password is required right now. Next enter the mysql commands to update the root password (replace "mynewpassword" with the password you want to have):
update mysql.user set password=PASSWORD('mynewpassword') where user='root';
exit;

Now shut down the insecure server:
killall -TERM /usr/sbin/mysqld

At this point, the root passwords should be updated in the mysql.user table. Restart the server in the usual way for your system.

Options: ReplyQuote


Subject
Written By
Posted
February 10, 2011 10:50AM
Re: any cheat-sheet style documents?
February 10, 2011 11:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.