Friday, February 22, 2013

Re-enabling --skip-grants-table

Ok...

So, I had forgotten what my MYSQL root password was from when I originally set up my Ubuntu server.  I followed one of the tutorials I found online that uggested the following:

sudo /etc/init.d/mysql stop
sudo mysqld --skip-grant-tables & mysql
mysql> use mysql;
mysql> INSERT INTO user VALUES ('localhost','root',password('newpassword'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);



...and that was about where I stopped reading ('cause I'm an impatient knob)...
(*note: the query above is as it appeared in the tutorial.  ...but it seems out of date as it is missing some field values.  I had to cross-reference the table structure and add the missing fields to the query.)

...which was a mistake because I missed some important steps... 

When I then tried to run a shell script I was working on (to automate the setting up of a development workflow) - that involved setting up some databases - I would get a message telling me that the command could not be executed because MYSQL was running with --skip-grants-table enabled.

A number of forum posts suggested that simply restarting the MYSQL service would remedy this.  Unfortunately, this was not the case.  I repeatedly tried stopping and starting MYSQL but I always got the same message.

Fortunately, I was able to find the original post.  ...which gave the steps I was missing:

mysql>flush privileges;
mysql>quit
sudo killall mysqld
sudo /etc/init.d/mysql start


...see, I never managed to kill the mysqld process.

Once I did, everything started working as desired.

No comments: