Hope this helps someone else. My starting point was a Ubuntu server where I had root access in the shell, but had never written down the root mysql password when I installed the mysqld service. I wanted to enable remote access so I could use the fabulous Sequel Pro database tool, but my regular user didn’t have GRANT privileges, so I couldn’t alter the mysql.user table from the command-line. This took some scraping around the net, and I had to combine instructions written for Windows with the usual Unix instructions to get this all going.
- Shell into the server, move into the /etc/mysql directory, and (as root – very important) use your favorite command-line editor to open /etc/mysql/my.cnf.
- Locate the line that reads
tmpdir = /tmpand insert a new line under that that reads
skip-grant-tables, save the file and exit your editor.
- Still as root, issue the command
ps auxc | grep mysqland note the process id of the mysqld service. The result will look like
mysql 4122 0.0 2.9 184592 31652 ? Ssl 19:48 0:00 mysqldwhere the word mysql is the user running the command, 4122 is the process ID (the thing you need) and all the way at the right is the command name mysqld.
- Copy the process id, then type the command
kill [paste the id]and press return. mysqld will restart automatically in a heartbeat, since it was started with the mysqld_safe script at startup, and it cannot be killed for very long.
Now you have a mysql server that ANYONE can connect to without a password and do anything at all. So working very quickly, connect to the server (either in the local shell or a desktop app) and issue the following query:
UPDATE mysql.user SET Password=PASSWORD('your_new_password') WHERE User='root';.
This should succeed. Next, edit my.cnf again, remove the line about skip-grant-tables and save, then find the process id for mysqld again, kill it, and you are all set. Root is once again accessible using a password, and the grant tables will be used so all of the security is back in place.
Oh, and now you should write that password down somewhere safe.
dynamo mailing list
Update your subscriptions at: