Disable Table Locking in mysqldump

I have a cron job on a web server that periodically runs mysqldump and emails me a zip file containing the database backups. I looked at one of them recently, and instead of the full DB dump, all it had in was this:

-- MySQL dump 10.11
--
-- Host: localhost    Database: dbname
-- ------------------------------------------------------
-- Server version	5.0.37-standard-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE
='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

…and when I try running sqldump from the command line I get:

mysqldump: Got error: 1044: Access denied for user ‘usrname’@'%’ to database ‘dbname’ when using LOCK TABLES

After lots of fruitless Googling, I came across this page, which says the problem can be overcome by using the “–skip-lock-tables” flag, like this:

  mysqldump --skip-lock-tables -u usrname -p  dbname >  backup.sql

Worked perfectly!

Crontab Under Mac OS X 10.5 (Leopard)

Beware - if you use crontab and are upgrading to Mac OS X 10.5 (Leopard), your existing crontab files will be DELETED by the upgrade!**(actually only moved & disabled - see comments) Back ‘em up first (yeah, I know you should always do a backup before upgrading, but this is really the only issue I found).

Also note that Leopard’s firewall seems to let everything through by default, even if that’s not what you previously had your firewall set to do.

Ejecting a Stuck CD or DVD from Mac Mini

If the disc is stuck in the drive but not mounted (i.e. doesn’t show up in the finder), and everything else has failed (eject button, F12, Cmd-E etc), and you want to eject the disk without having to reboot - for all you “uptime” junkies :-) - then try this in a terminal window:

drutil tray eject

and hit return. If that doesn’t work, try:

drutil list

This lists all removable drives you have connected.
Then type:

drutil tray eject n

where “n” is the number of the drive to be ejected.

Thanks to MacFixIt.com for this

“Unknown Hard Error” Pop-Up Dialogs After Crash in Windows XP

I was using Visual Studio.NET 2005 on my Windows XP box last night (don’t flame me - I also program in Java and have several Macs), when suddenly the machine just restarted itself for no apparent reason; no blue screen, nothing - just a reboot.

When it started again, i got a pop-up dialog at the login screen. The title bar said “DfrgNtfs.exe - System Error”, and the message in the box was the unbelievably helpful “Unknown Hard Error”.

I tried looking in the system Event Log to see if I could find any clues there… - oops! I got the same “Unknown Hard Error” popup dialog - this time, with “mmc.exe - System Error” in the title bar. I tried opening a command prompt - nothing happened.

In order to try to read the crash dump file (C:WINDOWSMinidumpMini120105-01.dmp), I downloaded the microsoft free Windows debugger - WinDbg - as described in this good article:

http://www.networkworld.com/news/2005/041105-windows-crash.html?page=1

However - when I try to install it, I get another “Unknown Hard Error” popup, with “msiexec.exe” in the title bar (starting to see a pattern, here…??)

I googled, and found several people saying it could be a hardware problem - notably hard disk or ram - so I did a full disk check - no improvement. I then figured that maybe the crash was caused by some other problem, but that it must have left some system files in a corrupted state, which, in turn, caused the pop-ups.

I eventually found a discussion group where someone (unfortunately, I didn’t save the link) recommended the windows command-line command: sfc /scannow - that checks all the win system files for corruption (and possibly bribery), and repairs them from your Windows XP install disk if problems are found. I ran that from the “start menu -> run” dialog, and some of the popups stopped…, well…, popping up (notably the DfrgNtfs.exe ones), but i still got them when trying to view the event log or trying to install software.

Finally, I found the answer. The files that the System, Application and Security events are written to (the ones you view from the Event Viewer) had been corrupted - so I guess whenever I tried to do something that would create an entry in one of these logs, I got an error. The solution was found on this page:

“How to Delete Corrupt Event Viewer Log Files”
http://support.microsoft.com/?kbid=172156

…which basically says - disable the event logging service in the “Services” dialog; reboot; delete the following files from C:WINDOWSsystem32config: AppEvent.Evt, SecEvent.Evt and SysEvent.Evt (or rename them as a backup); set the event logging service back to “automatic” startup; reboot

That solved all my problems…

Setting up LDAP (slapd) on Mac OS X (non-server edition)

I have been wanting a centralized address book/contacts solution for a long time, and was looking for something that used open standards, and saved stuff in plain text, or could export to plain text. If Thunderbird could also access it directly, that would be perfect, but what hope was there? I looked at Synckolab (http://www.gargan.org/extensions/synckolab.html) - which is an excellent idea, but not ready for primetime. I poked around for a long time, knowing at the back of my mind that LDAP was probably the best way to go, but I just didn’t want to go through the pain of installing and setting it all up, only to have to do it all again next time I upgrade my operating system (I’d just been through similar pain with my mail server setup, converting from OS X Panther to OS X Tiger - non-server versions). The whole reason I got a mac to use as my server (mac mini, 1.25GHz, 512MB RAM) was so I didn’t have to deal with Linux - life’s too short.

However, my research indicated that even the non-server version of Mac OS X ships with an LDAP server (but no UI tools for setup/admin). Furthermore, all the parts you need can also be downloaded, installed and updated via Fink (http://fink.sourceforge.net/). Having seen posts from people who had problems getting the mac-shipped version to work, I decided to go the Fink route.

So here it is - pretty straightforward, really…

First - download and install Fink (http://fink.sourceforge.net/) and then FinkCommander (http://finkcommander.sourceforge.net/), and do selfupdate and update-all (see the “source” menu)

1) in FinkCommander, install:

openssl097 0.9.7d-1 Secure Sockets Layer and general crypto library
openssl097-shlibs 0.9.7d-1 Secure Sockets Layer and general crypto library

openldap-ssl 2.1.22-25 LDAP directory services implementation
openldap-ssl-shlibs 2.1.22-25 Shared libraries for LDAP

cyrus-sasl2-shlibs 2.1.21-3 Cyrus Simple Auth. and Security Layer Library
cyrus-sasl2 2.1.21-3 Cyrus Simple Auth. and Security Layer Library
cyrus-sasl2-doc 2.1.21-3 Cyrus Simple Auth. and Security Layer Library

If you don’t see these, there’s a setting in the preferences, on the fink tab, that says: “use unstable packages” - mine’s checked, but I’m not sure if these fell into that category or or not)

2) in terminal, type:

sudo vim /sw/etc/openldap/slapd.conf

and scroll down to find this:

include /sw/etc/openldap/schema/core.schema

and beneath it, add:

# ADD THESE: ##
include /sw/etc/openldap/schema/cosine.schema
include /sw/etc/openldap/schema/inetorgperson.schema
include /sw/etc/openldap/schema/mozillaOrgPerson.schema
##############

(IMPORTANT: don’t forget to get a copy of mozillaOrgPerson.schema and put it in the above location. It can be downloaded via a google search. I used version 0.6.3)

Now scroll down to find this:

#######################################################################
# ldbm database definitions
#######################################################################


database bdb
suffix "dc=my-domain,dc=com"
rootdn "cn=Manager,dc=my-domain,dc=com"

Replace “my-domain” with your real domain name. (For other settings, if required, see “man slapd.conf”).

Save & exit.

To test whether the configuration file is correct or not, type:

sudo /sw/sbin/slapd -d 5 -t

which tests the config file (with level 5 debugging, to tell you why it’s failing, if it is)

3) AS ROOT, start ldap (slapd) with *lots* of console debugging:

/sw/sbin/slapd -d 255

Also see “man slapd”

4) AS ROOT, set up using these instructions:

http://www.onlamp.com/pub/a/onlamp/2003/03/27/ldap_ab.html

My install differed from this in the following ways (refer to the above-linked page to understand how these fit in):

Here’s my directory.ldif file:

dn: dc=my-domain,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
dc: my-domain
o: my-domain

dn: ou=addressbook,dc=my-domain,dc=com
objectClass: top
objectClass: organizationalUnit
ou: addressbook

***NOTE*** - MUST have the blank line between “o: my-domain” and “dn: ou=addressbook…etc”

Here’s the command line to add it to the directory:

ldapadd -D 'cn=Manager, dc=my-domain, dc=com' -x -f directory.ldif -W

(Had to add the -W -x -D ‘cn=…’ option to bind as that name, otherwise it tries to use SASL)

Command line to do initial search:

ldapsearch -W -x -D 'cn=Manager, dc=my-domain, dc=com' -b 'dc=my-domain, dc=com'
'objectclass=*'

(Had to add the -W -x -D ‘cn=…’ option to bind as that name, otherwise it tries to use SASL)

TO ADD AN ENTRY:

cn=Test User,cn=Test User,ou=addressbook,dc=my-domain,dc=com
givenName Test
sn User
cn Test User
street 123 Main St
o myCompany
l My Town
st CA
postalCode 50005
telephoneNumber 888 888 8888
mobile no mobile
facsimileTelephoneNumber 888 888 8888
mail me@my-domain.com

…next post - Importing Contacts from Thunderbird Addressbook into LDAP - will show how to export existing address book contacts from mozilla thunderbird and import them into your LDAP server…