Posts tagged as:

mysql

MySQL gem on OSX Leopard 10.5.x

February 17, 2009

No Gravatar

sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

I started to play with Rails 2.3 and ran into a little issue trying to access my database. I guess I shouldn’t have been ignoring all those depreciation warnings…oops. Naturally, the first thing I did was run “sudo gem install mysql” which threw the following error:

ng$ sudo gem install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
	ERROR: Failed to build gem native extension.
 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
 
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out

After digging around, I found the following command:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed

Looks like it was successful…but wait, let’s check. Pop into IRB:

>> require 'mysql'
LoadError: 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
	from /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
	from (irb):1

Further searching revelaed the solution:

sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

{ Comments }

adapter: mysql (ArgumentError)

February 16, 2009

No Gravatar

I was up late working on a project and I kept running into this error after I tried to deploy to my staging server. It turns out you can’t use tabs in a YAML file. Oops..after I removed the tabs and used spaces my app started successfully.

 
/usr/lib64/ruby/1.8/yaml.rb:133:in `load': syntax error on line 18, col 3: `   adapter: mysql' (ArgumentError)
	from /usr/lib64/ruby/1.8/yaml.rb:133:in `load'
	from /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:716:in `database_configuration'
	from /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:340:in `initialize_database'
	from /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:124:in `process'
	from /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `send'
	from /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `run'

{ Comments }

Import a MySQL dumpfile into your database

March 4, 2008

No Gravatar

After you have used MySQL to dump your database, FTP that dump file to an accessible directory on your server.

Once you have uploaded the dump file to your account here, make your way back to command line and get ready to import the file!

Now to import the dump file into MySQL, use the following command at your shell prompt:

# USER is your MySQL username
# DBSERVER is your database servername, not always required
# dbname is your database name<br># dbname.sql is the dump file you are importing
# -p will prompt for your password
 
mysql -u USER -p -h DBSERVER dbname < dbname.sql

If your preferences are properly set, the same thing can be accomplished with:

mysql < dbname.sql

Enjoy!

{ Comments }

214-748-3647

February 27, 2008

No Gravatar

The number is 214-748-3647, and as fate has it…somebody from Texas is very unlucky.

One of the sites I have been working on saves the phone numbers of condominiums to the database. Take a slight oversight on my part, mix in a improperly declared column type, and poof…you have phone numbers storing incorrectly.

What did I learn from this little fiasco? It seems that phone numbers should be stored as strings, and not integers. More importantly, I should never get a phone number that is 231 -1.

{ Comments }