Showing posts with label MySql. Show all posts
Showing posts with label MySql. Show all posts

Sunday, December 11, 2011

installing rails on OSX with mysql

trying to install and use ruby on rails on OSX with a mysql installation made by hand in /usr/local/mysql


$ rails server/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql-5.5.17-osx10.6-x86/lib/libmysqlclient.18.dylib (LoadError)  
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle  
Reason: no suitable image found.

I'm probably missing something about a correct installation on osx and with a correct distribution of mysql libraries but I've seen that the fastest way of getting rid of this problem was a:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

use the

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle

should be the proper solution

Tuesday, February 23, 2010

DBD::mysql on Leopard


I've encountered this problem

dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: dynamic lookup

dyld: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: dynamic lookup


I always have problems due to multiple installation of mysql my hand, 32 and 64 bit, and 2 different installations of perl (one coming from Leopard, the other from port).

To solve this (due to 64bit mysql libraries and missing 32bit libs) I decided to recompile DBD::mysql on my box in CPAN

CPAN> force install DBD::mysql

and apparently this solved the problem

Monday, December 28, 2009

will Mysql die ?

http://monty-says.blogspot.com/2009/12/help-saving-mysql.html

Tuesday, March 03, 2009

reset mysql password


just a short memo, as usual:

stop mysql

restart in safe mode:

mysqld_safe --skip-grant-tables &

enter as root, now:

mysql -u root

and reset table password:

use mysql
update user set password=PASSWORD('newpassword') where user='root';

Tuesday, December 09, 2008

install LAMP (Apache - mysql - php) on Ubuntu

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install mysql-server-5.0

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

Thursday, July 31, 2008

last n records in a query

I'm using mysql for this:

This is straightforward:

SELECT * FROM tab LIMIT 0, 10

will display the first 10 rows from the table tab.

SELECT * FROM tab LIMIT 5, 2

display rows 6 and 7 (5 is the offset, 2 the count)

And:

select * from (select * from TAB order by id desc limit 5 ) TA order by id;

display the LAST 5 rows.

Monday, July 14, 2008

MYSQL: convert null as 0

IFNULL():

like in:
SELECT IFNULL(field, 0) FROM tab;