Monday, August 6, 2007

ERROR 2013 (HY000): Lost connection to MySQL server during query

I've got a brand new Ubuntu 7.04 install. I installed MySQL, edited /etc/mysql/my.cnf to allow connections from my local network, but no matter what I did, I always got the following error on trying to connect to the MySQL server from a different machine:

ERROR 2013 (HY000): Lost connection to MySQL server during query

The relevant area of /etc/mysql/my.cnf:

[mysqld]
bind-address = 192.168.0.23

After hours and hours of searching, I found the following solution:


1) /etc/hosts.allow was missing in this version of Ubuntu. You can add them in this way:

sudo apt-get install tcpd

2) I added the following to my new /etc/hosts.allow file:

mysqld: 192.168.0.*


That's it! This now allows me to connect to this MySQL server from any machine on my local network. From what I understand, MySQL on Ubuntu is built with libwrap and that's why you need to edit the /etc/hosts.allow file in this case. I'm no expert, but it worked for me.


The relevant documents are here:

Mysql Docs (see the comments from March 2, 2004)

hosts.allow (useful tips for getting started)

Related:
iptables rule to allow mysql (if you're not an iptables expert)

Thursday, March 1, 2007

Fixing Line Breaks in Perl

Here is a handy Perl one-liner that I use a lot:

perl -pi -e 's/\r/\n/g' FILENAME

This one is useful for Excel Spreadsheets in OS X. When you export data into a delimited file and then open it in VI, the line breaks don't show up. At least, that's what happens with my very old version of Excel. Using the above one-liner on the file converts the carriage returns into line breaks that VI can interpret properly.

There's a much more thorough explanation here, which is where I got the idea from initially.

Tuesday, February 20, 2007

Subclipse (OS X) and Samba Shares

If you're having problems connecting to a Samba share (ie switching to a workspace on a Samba share), you may need to disable locking in Eclipse. Yesterday on my iMac, every time I tried to create a workspace on a Samba share I was trying to connect to on the local network, I got errors about the workspace being in use. After a lot of digging around, here's my solution:

You need to edit the eclipse.ini file. On my Mac, Eclipse is in the Applications folder. So,

vi /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini

I added the following line to the end of the file:

-Dosgi.locking=none

After restarting Eclipse I had no more issues with file locking or the workspace being busy.

.perltidyrc According to Perl Best Practices

The following is a valid .perltidyrc file as listed in Perl Best Practices:

-l=78 # Max line width is 78 cols
-i=4 # Indent level is 4 cols
-ci=4 # Continuation indent is 4 cols
-st # Output to STDOUT
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=0 # No extra indentation for closing brackets
-pt=1 # Medium parenthesis tightness
-bt=1 # Medium brace tightness
-sbt=1 # Medium square bracket tightness
-bbt=1 # Medium block brace tightness
-nsfs # No space before semicolons
-nolq # Don't outdent long quoted strings
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" # Break before all operators

A Quick Intro

What you'll find here is various bits of trivia that have helped me fix day to day computer issues with Linux machines, Macs etc. When the docs aren't easy to find, it's good to post the little things you've learned in one place. That's my plan here. I'm putting everything here for my own benefit -- I'd like to have a central location for my notes to self, but if it's helpful to someone else, that's great!