WineBottler, WineHQ, Holy Crap!

For Our Few Windows Apps

I’ve been running my last remaining Windows apps, or any new ones I have to run for whatever reason, either on my one real Windows machine, or under Parallels or, more recently, VirtualBox.

We keep the battered old EMachines ET6212 with a whopping 2GB of memory and Windows XP around mostly to run QuickBooks since the Mac version of QuickBooks sucks, can’t convert our old data, etc. I do have one SEO program that I’m still using on that Windows machine, mostly because it keeps the Windows annoyance off my main Mac and it mostly runs scheduled SEO check jobs anyway.

Any time we do have to run a Windows program, I go back to my trusty old Windows 2000 disks and fire up a new Virtual Machine under Parallels or VirtualBox. Fortunately, there have been few programs that won’t run on that now 10 year old (!) OS.

Wine, WineBottler

Today, I was looking for an SQL query building GUI and came across a post that said that SQLyog was still the best MySQL application out there and gave instructions for running it under Wine.

The link from that page was broken but eventually lead me to WineBottler which is apparently the latest greatest effort to make a seamless bundle of Windows apps to run on OS X without a full emulator like Parallels or VirtualBox.

I downloaded WineBottler, opened the DMG, and dragged Wine.app and WineBottler.app to my Applications folder. Go Mac installation.

SQLyog Community Edition

Downloaded the SQLyog Community Edition (what the hell is up with that name?) from this page, then Opened With Wine. This started the automatic bundling process and eventually, after opening and closing a bunch of windows that I didn’t keep much track of, I told it to save SQLyog821CommunityEdition.app to my Desktop, which it did. In the course of all this, it also opened the Windows program!

So there it was, a Mac Application bundle that contained a Windows program, and a Windows program I’d never seen before running on my desktop with no big Windows VM hogging up CPU and memory.

After clearing the nag screens that are part of the SQLyog Community Edition Experience, I poked around, and damn if it didn’t actually seem to work.

Now, to see if it’s actually a better tool than the two Mac ones I’ve been exploring: Sequel Pro, and Querious.

My First Tomcat Experience

I’ve decided, for various reasons, to use Jasper Reports to do the reporting for our app.

I hired someone to help with the initial Tomcat setup; boy am I glad I did…

The project that I contracted was to create a script to set up Tomcat, with Jasper Server, to access MySQL, with example Python scripts to trigger and pull down pre-cooked reports.

So far we’ve got Tomcat running on one port, Apache 2 running on another, the Jasper web UI pages being served by Tomcat, phpMyAdmin set up and working and MySQL accessible from our local network by IP and locally on the server.

At least until this morning.

As per a previous post, I had enabled remote access to MySQL by modifying the `my.cnf` file and, at that time, I had questioned whether having two `bind-address` statements in the config would work.

This morning, I couldn’t connect to the Jasper server either locally on the server itself or remotely from within my networkand, in the sea of Java exception messages, I pulled out `AccessControlException` and went hunting.

I found this post:

The Problem:

When our webapp trys to connect to the database on localhost, an exception

‘java.security.AccessControlException: access denied
(java.net.SocketPermission localhost resolve)’

Well, that kind of looks like what I’m getting.

So, it would seem that I can’t access the local MySQL server via localhost’s IP address any more which would make sense if it’s a “whoever gets there last” scheme for IP addresses in the configuration.

But phpMyAdmin Can Do It!

Thing is…phpMyAdmin is still working, so it is able to get at the local MySQL so perhaps it’s just a difference in how they specify local access; maybe Tomcat’s not using the local port?

I figured I’d work from what was working (phpMyAdmin) backwards so I started looking for the configuration files.

Holy crap.

Check this out:

$ sudo find / -name phpmyadmin
/usr/share/dbconfig-common/data/phpmyadmin
/usr/share/doc-base/phpmyadmin
/usr/share/doc/phpmyadmin
/usr/share/phpmyadmin
/etc/phpmyadmin
/var/lib/doc-base/omf/phpmyadmin
/var/lib/doc-base/documents/phpmyadmin
/var/lib/phpmyadmin

WTF?! Nine (9) different places where pieces of phpMyAdmin had ended up? I understand that documentation might be separate, but is this really necessary?

Note that this is how it is set up by using the Ubuntu `aptitude` utility which is very damn handy but this is just silly.

Turns out that the actual PHP files for the server are in `/usr/share/phpmyadmin` and the actual database access configuration seems to be in ` /etc/dbconfig-common/phpmyadmin.conf`, which actually just fills in the `pma_table_info` table with default access information.

In `phpmyadmin.conf`, where it fills in the `pma_table_info` record, the only thing actually specified is `mysql` as the database type. The host and port are left blank as shown below:

# dbc_dbserver: database host.  
#       leave unset to use localhost (or a more efficient local method
#       if it exists).
dbc_dbserver=''

# dbc_dbport: remote database port
#       leave unset to use the default.  only applicable if you are
#       using a remote database.
dbc_dbport=''

So, I went and did the same thing to Jasper’s configuration file at ` /var/lib/tomcat6/conf/Catalina/localhost/jasperserver.xml`

I changed the line:

       url="jdbc:mysql://localhost:3306/jasperserver?useUnicode=true&characterEncoding=UTF-8"  

to read:

        url="jdbc:mysql:///jasperserver?useUnicode=true&characterEncoding=UTF-8" 

Restarted the server with:

	#  sudo /etc/init.d/tomcat6 restart

No joy.

Bind to One or All

Well, I still don’t have a satisfactory reason for why phpMyAdmin can connect to the server whether localhost is specified or not but I suspect it’s something Java-ish that I’ll just have to ask my guy about after New Years.

For now…

You can either have MySQL bind to one address, or all. After a bit more poking around, I finally found the doc and now it says that ‘whoever gets there last wins’ where previous versions didn’t address the issue.

So…if I want to restrict access, I can do it through a combination of firewall settings and permissions in the database.

Enable Remote Access to MySQL

I haven’t set MySQL up in years; it’s always on the server, and I guess we never try to access it from outside.

So… I had completely forgotten about allowing access. Fortunately, it only took a few quick Googles before I had the answer and, even though it’s in a million other places, I’m going to add it here since I want to be able to use this blog as my reference.

Edit, on Ubuntu, with:

	$ sudo vim /etc/mysql/my.cnf

And make it look like this:

[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 127.0.0.1
bind-address = you.re.ip.add
# skip-networking

In 5.1.x it seems that `skip-networking` has been dropped as the default and `bind-address` is 127.0.0.1 by default. I just left that in place and added my IP address. I’m not sure if that’s right, but it works.

I found the full reference here. I really like that ‘nixCraft’ site; I seem to end up there a lot.

Stupid MySQL Python with Stupid 64 bit MySQL on Stupid 64 bit Snow Leopard

So…

I’ve decided to go with MySQL for my latest product for a variety of reasons.

To build MySQL support for Python, you have to have the MySQL headers and such available.

Even though I installed from the MySQL supported binary for OS X 10.6, the MySQL-python installer couldn’t find the support files.

To get it to work, I had to edit `site.cfg` in the `MySQL-python-1.2.3c1` directory to uncomment out line 13 and edit it to read:

mysql_config = /usr/local/mysql/bin/mysql_config

The comment in the code says, above that:

# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.

Well, isn’t that special…

Then, to add insult to stupidity:

  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 13, in 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init function (init_mysql)

I found some instructions that suggested trashing the build directory, then executing the following (I broke it into separate lines):

# export ARCHFLAGS="-arch x86_64"
# python setup.py build
# sudo python setup.py install

This, however, gave me the same error on import.

So, I trashed `build`, `dist`, and `*.egg-info` and tried again.

Same shit.

So, I dug a little deeper. Of course, there’s always the suggestion that one build MySQL from source, but that just seems melodramatic.

It’s not complaining about MySQL, it’s complaining about the module not defining an init function.

I hunted down this thread that seems to be right up to yesterday so obviously I’m not the only one arguing with this:

http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/

So far, the solutions all seem to say to run Python in 32 bit mode but that just seems idiotic. I’ve got 64 bit everything and this library just doesn’t seem to have correct build instructions. I’m not going to start crippling my system in the hopes of making it limp along; that’s just stupid.

Of course, it’s after 1am and so am I right now so I think I’ll stop…for now.