Tagged: mysql

Upgrade to MySQL 5.5.12 and now MySQL won’t start

I messed up my local install of MySQL (it's a long story that involves me almost throwing a punch to my 30" monitor). I finally gave up, deleted everything MySQL related according to these notes and then I used homebrew to do a clean install.

After the install I started getting this error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 

I couldn't figure out what was going on so I checked my logs in /usr/local/var/mysql (in that directory find a file that ends in .err). Here's what I kept seeing over and over again:

110705 14:33:20 [ERROR] /usr/local/Cellar/mysql/5.5.12/bin/mysqld: unknown variable 'default-character-set=utf8' 110705 14:33:20 [ERROR] Aborting 

Turns out if you upgrade MySQL you'll want to modify /etc/my.cnf. This line causes problems:

default-character-set = utf8 

Remove that and you should be good. For reference here's what my '/etc/my.cnf' file looks like:

[mysqld] max_allowed_packet=64M coll...

Continue Reading →

Brew Install MySQL Issue

I ran into a problem while trying to install mysql using homebrew:

~/projects/oerglue (master)$ brew install mysql ==> Downloading http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.12.tar.gz curl: (7) couldn't connect to host Error: Failure while executing: /usr/bin/curl -f#LA Homebrew 0.8 (Ruby 1.8.7-174; Mac OS X 10.6.8) http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.12.tar.gz -o /Users/jbasdf/Library/Caches/Homebrew/mysql-5.5.12.tar.gz 

Basically, the script couldn't find the mysql source code.

Luckily homebrew uses ruby. So fixing the problem was really easy. Just edit the mysql.rb homebrew formula found here:


I just changed the url and md5 like so:

url 'http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.5/mysql-5.5.13.tar.gz' md5 'f0e519e90ee7c00fceb0730edf859d7b' 

Then everything worked great. One note, if you want to change the version or use a different mirror for mysql be sure to get the 'Source Code' version ...

Continue Reading →

ActiveRecord::StatementInvalid: Mysql::Error: Got error 139 from storage engine

I ran into a 'fun' error with an application I've been working on. Everything was running fine and then one day hoptoad started filling up with exceptions like this:

 ActiveRecord::StatementInvalid: Mysql::Error: Got error 139 from storage engine 

I hate errors like that. Lucky for me there's Google: http://forums.mysql.com/read.php?22,63584,166521#msg-166521 http://bugs.mysql.com/bug.php?id=10035

Turns out that each row in mysql has a limit of 8000 bytes. A 'text' column takes up 768 bytes in the row after that it moves the data to an db external page. When you have Rails migrations you forget how many 'text' columns you have. Turns out I had 14:

14 x 768 = 10752 bytes

What's interesting is that you can get away with this setup until one day one of your users enters a lot of data. At that moment you will get the dreaded:

 ActiveRecord::StatementInvalid: Mysql::Error: Got error 139 from storage engine 

Time to refactor and break the table apart. I di...

Continue Reading →

Setting Up mysql as utf8 for Ruby on Rails using homebrew

It took me far to much time to get this to work right so hopefully this is helpful for someone (probably me at some point in the future).

The hashrocket guys have a great writeup on configuring your development environment. I didn't need some of their bash configuration but it's a great starting place.

Once you have mysql installed with homebrew it can still be handy to customize your mysql configuration. Here's an article on how to configure my.cnf.

My configuration ended up looking like the code below which I got from this article. Here's more info on the values you can specify. I placed the code into '/etc/my.cnf'. That's probably more global than most people want, but it works great for me.

[mysqld] #Max packetlength to send/receive from to server. max_allowed_packet=64M #socket = /var/mysql/mysql.sock character-set-server = utf8 default-character-set = utf8 #This option makes InnoDB to store each created table into its own .ibd file. innodb_file_per_tab...

Continue Reading →

Configure Your wp-config.php for Database Access on Mac OSX 10.6

I ran into another problem trying to get my database to work on 10.6. The trick is to properly set DB_HOST:

 /* MySQL hostname / define('DB_HOST', ''); 

For a complete tutorial on how to setup Wordpress on Mac OSX 10.6 see http://wordpress.org/support/topic/306878?replies=6.

Continue Reading →

Install Native MySQL Gem – Edge Rails Stopped Including It

I decided to try out the latest edge Rails and I started getting this error:

 !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. /!\ FAILSAFE /!\ Mon Jul 28 22:58:38 -0600 2008 Status: 500 Internal Server Error dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle 

At first I tried:

 sudo gem install mysql 

which of course didn't work because it never works. You have to tell the complier where to find stuff. Do this:

 sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 

Continue Reading →