Insane “out-of-the-box” thinking
Last night's redacted rant [1] (okay, technically very early this morning) had to do with a crisis of confidence at work (the proverbial straw [2] last night was replying to a trouble ticket with a huge rant with some fairly strong language <cough cough> about package management systems [3] and forgetting to tick the “staff only” option—oops) and wondering why Smirk even puts up with my curmudgeonly tendencies.
I guess I found out why today. Smirk called with a rather interesting problem. One of our clients lost the administrative password to MySQL [4] and could we reset it? We didn't have the administrative password either. Smirk tried the “recommended procedure” in this case:
- 1. Shutdown MySQL: /etc/init.d/mysql stop
- 2. Restart MySQL with an option to bypass authentication: mysqld_safe skip-grant-tables &
- 3. Reset the administrative password: mysqladmin -u root password "newpassword" (or some variation on this—there are several different ways to do this actually)
- 4. Shutdown MySQL—here you may need to find the process id and kill it, since you didn't use the startup scripts to start it.
- 5. Restart MySQL using the startup scripts: /etc/init.d/mysql start
only to fail in step three. That's when he called me.
I did get the password reset, which is what Smirk (and the customer) really wanted. What I did not do was:
- 1. Shutdown MySQL: /etc/init.d/mysql stop
- 2. Create the text file $HOME/mysql-init with the following contents:
- 2. * 2. > * 2. >
- 2. > ```
- 2. > UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
- 2. > FLUSH PRIVILEGES;
- 2. >
- 2. > ```
- 2. >
- 3. Restart MySQL: mysqld_safe --init-file=$HOME/mysql-init &
- 4. Delete the text file: /bin/rm $HOME/mysql-init
(as I found out after the fact). No, I think differently. I live on the edge. I do things the hard core way:
- 1. Shutdown MySQL: /etc/init.d/mysql stop
- 2. Copy critical files: /var/lib/mysql/mysql/user.* /tmp/
- 3. Using a binary editor, zero out the administrative password in the file /var/lib/mysql/mysql/user.MYD (told you I live on the edge, and yes, I used a binary editor I wrote for this—Muahahahaha!)
- 4. Restart MySQL: /etc/init.d/mysql start
- 5. Reset the administrative password for MySQL
I think Smirk keeps me around for my “out-of-the-box” (or is that “out-of-my-ever-loving-mind”?) thinking.
[1] /boston/2009/03/04.1
[2] http://en.wikipedia.org/wiki/Last_straw
[3] http://en.wikipedia.org/wiki/Package_management_system
[4] http://www.mysql.com/
Gemini Mention this post
Contact the author