mysql

Mysql Error 1064 (4200) - Using BTREE

Trying to move a database from my development machine which is running MySQL 5.1.41 on Ubuntu to my server, which is Ubuntu but runs MySQL 5.0.51a and I keep getting an error:
ERROR 1064 (42000) at line 122: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE, KEY `FrtTP_Feature` (`featureId`), CONSTRAINT `FrtTP_Feature` F' at line 4

On my development machine, I can dump and upload the database just fine, but it won't import all the tables to MySQL on my production box. Obviously the differing MySQL versions are causing problems. I searched on the internets, but nothing much useful came up, as that error seems to be used for everything. I'm finding out that MySQL's errors are anything but informative.

After some digging on MySQL's site, I found the syntax USING BTREE has moved to after the key description in versions greater than 5.1. After changing my database dump file, I can now upload all my tables and data to my production server. You would think they would wait until major version numbers to choke on the placement of that syntax.... Below are the changes I made to get 5.1.41 to work with 5.0.51a:
UNIQUE KEY `url_unique` (`url`,`memberId`) USING BTREE becomes UNIQUE KEY `url_unique` USING BTREE (`url`,`memberId`) and
PRIMARY KEY (`memberId`,`tripreportPhotoId`) USING BTREE becomes PRIMARY KEY USING BTREE (`memberId`,`tripreportPhotoId`)

Posted In: mysql | 3 comments

Mysql Error 1005 - Foreign Key Contraint Woes

If you are trying to set up foreign key constraints in MySQL InnoDb table, and run into Error 1005, open up a mysql client on the command line and type show engine innodb status. Then scroll through the output until you reach:
------------------------
LATEST FOREIGN KEY ERROR
------------------------

This will give you more information about the error. The foreign key names have to be unique, so if you use something generic for the name, you may run into issues when setting up constraints on other tables. The other error I have experienced was trying to set the on delete action to set the field null, but null was not allowed on that field.

Posted In: mysql | No Comments

Mysql WorkBench 5.1 on Linux/Ubuntu


I am building a new database driven website for fun and decided to check on teh status of Workbench and see if they had a Linux version. As luck would have it, they launched a Linux version a couple of days ago! I downloaded the binary for Ubuntu from MySQL and tried to run it, but it spewed out errors. Searching around some more, I found an article on MySQL that talking about building from source on Ubuntu, and copied and pasted the apt-get install for all the dependencies.

I opened a terminal, cd'ed to the bin directory and issued "./mysql-workbench" and voila, the program opened. After creating a new diagram and trying to edit a table, I got a segfault. Looks like I'll have to build it. Following the aforementioned article, I issued "sudo apt-get install libcairo2-dev", and found that I already had that library installed, so I followed the directions and installed Google's ctemplate library. Then I downloaded source, complied to tried to install and ran into errors - most of which had to do with Cairo. Upon closer inspection, I realized I didn't Cairo build with support for glitz, just used the version available with Ubuntu. Ahhh, the joys of Linux. Back to the drawing board, where I was able to install Cairo with Glitz enabled, then compile Workbench from source. Quickly had a chance to play around with it and it is no longer segfaulting when I edit a table, but not sure how stable it is until I get more time.

To recap, here is what I did to get it working:

  1. sudo apt-get install autoconf automake libtool libzip-dev libxml2-dev libsigc++-2.0-dev libglade2-dev libgtkmm-2.4-dev libglu1-mesa-dev libmysqlclient15-dev uuid-dev liblua5.1-dev libglitz-dev libglitz-glx-dev libpixman-1-dev libpcre3-dev g++ libgnome2-dev libgtk2.0-dev libpango1.0-dev

  2. sudo apt-get source cairo

  3. Extract the cairo tarball and cd into the folder

  4. ./configure -enable-glitz

  5. make

  6. make install

  7. Download the source for workbench and extract it, and cd into the folder

  8. ./autogen.sh

  9. make

  10. make install DESTDIR=/home/rlbolton/apps/mysql-workbench (obviously choose a destination dir appropriate for you)



I am actually amazed I got everything to work, considering my very limited knowledge of Linux. Now we'll see how stable the app is... And thanks to MySQL for making a Linux version!

Posted In: mysql, Ubuntu | 4 comments

Installing MySQL Query Browser on Fedora Core 5

I was visiting my parents back in Vermont last week, but right before I left I decided I wanted to install MySQL's Query browser. Running mysql from the command line works, but sometimes it is nice to have a GIU, especially since the program has help docs for syntax, multiple tabs open with queries and expandable table views (I always forget the names of rows in my tables while writing queries).



Fortuitously, I decided to search around before installing the program, and I quickly realized it wasn't as easy as issuing a yum command. I located a binary suitable for Fedora Core 5, and issued “ yum list installed | grep gtkhtml” and “yum list installed | grep gtkmm” to see if I had the prerequisite programs (gtkhtml3 and gtkmm24), as listed on the website with the binaries. I didn't have either of those, so I ran “sudo yum install gtkhtml3” and “sudo yum install gtkmm24”. Once those were installed, I downloaded the binary and MySQL Query Browser is working fine. Looking at the output from the previous yum list installed command, I have gtkhtml2, gtkhtml3 & gtkhtml36 - I can't remember now whether I also installed gtkhtml2 and gtkhtml36 for good measure, or if they were already there...

Posted In: Linux, Fedora Core 5, mysql | No Comments