Change or recover MySQL root password

To Change a Known Password
If you know the current password, use one of these methods to reset it.  If you do not know, skip ahead to the next section.

Using mysqladmin if there is no password:

$ mysqladmin -u root password <new password>

Using mysqladmin if there is a password:
$ mysqladmin -u root -p <old password> <new password>

Using mysql shell if there is no password
mysql -u root
mysql> update user set password=PASSWORD("<new password>") where User='root';
mysql> flush privileges;
mysql> quit

Using mysql shell if there is a password
mysql -u root -p
Password: <old password>
mysql> update user set password=PASSWORD("<new password>") where User='root';
mysql> flush privileges;
mysql> quit

Recover/reset the password if you don’t know it
There is no way to recover the password if you don’t know it, but you can reset it to something new.
You must have root on the box for this.

  1. Kill the running server
  2. Create a text file with the following contents:
    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;
  3. Run the mysql_safe binary with the --init-file option pointing to your new file like this:
    mysqld_safe --init-file=/path/to/file &
  4. Delete the init file you created.
  5. Stop and start MySQL normally.

Did you find this post useful or have questions or comments?  Please let me know!

Posted in How Tos, mysql | Tagged , | Leave a comment

Windows 2003 Update Group Policy

From Microsoft knowledgebase article http://support.microsoft.com/kb/298444

To update the group policy, run Gpupdate.exe from a cmd window.  This is refresh any changes in the Group Policy as they apply to that machine.  Run Gpupdate.exe /Force from a cmd window in order to force a full refresh of the Group Policy.

You have to check Event Log -> Application to see if it actually succeeded.

Did you find this post useful or have questions or comments?  Please let me know!

Posted in How Tos, microsoft, windows 2003 | Tagged , , | Leave a comment

How to update qmail relay rules

D. J. Bernstein’s Qmail, now in the public domain, is a powerful yet clumsy SMTP messaging system. One of the most common problems is updating the rules for allowing SMTP relay, or denying the same.

If you qmail-smtpd under tcpserver, the following will update relay allow and relay forbid rules.

Create a file called /etc/tcp.smtp and put in it:

127.:allow,RELAYCLIENT=""
1.1.1.1:allow,RELAYCLIENT=""
2.2.:allow,RELAYCLIENT=""
2.2.2.5:deny

Qmail uses simple pattern matching so only classful subnets are allowed. Sorry, no CIDR notation.

The example above will allow/deny:

  • Allow relaying from 127.* your localhost subnet of 127.0.0.0/8
  • Allow the /32 address of 1.1.1.1
  • Allow 2.2.* the /16 subnet of 2.2.0.0/16
  • Specifically forbid 2.2.2.5

In order to implement these rules you need to update the server tcp.smpt.cbd file and restart Qmail.

First, back up /etc/tcp.smtp, then run the command:
tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp

If the rules don’t update, make sure -x /etc/tcp.smtp.cdb is after tcpserver in your start script, then restart Qmail.

Did you find this post useful or have questions or comments?  Please let me know!

Posted in Email Servers, How Tos, qmail | Leave a comment