This is the simplest way to restart the server on Mac OSX that I found
my-computer:~ me$ mysqladmin -uroot -p shutdown
Enter password:
my-computer:~ me$ sudo mysqld_safe
Starting mysqld daemon with databases from /sw/var/mysql
Monday, October 20, 2008
Thursday, October 16, 2008
Wednesday, October 8, 2008
MySQL Python API
If you try to install the python API for MySQL on Leopard, and receive the following message:
lipo: can't open input file: /var/tmp//ccDsRjet.out (No such file or directory)
make sure you check out this.
lipo: can't open input file: /var/tmp//ccDsRjet.out (No such file or directory)
make sure you check out this.
Monday, June 9, 2008
Friday, June 6, 2008
Installing BerkeleyDB perl module from CPAN
I was getting an error executing:
cpan -i BerkeleyDB
This seemed to be because I did not have Berkeley installed on my mac. Well no problem, just execute
port install db46
from Macports. After that finishes, just set up a link in /usr/local e.g.
ln -s /usr/local/BerkeleyDB.4.6/ /usr/local/BerkeleyDB
and then
cpan -i BerkeleyDB
should work.
Tuesday, June 3, 2008
Enable sending email on Mac OS X
It wasn't completely obvious to me, but here is what you need to execute in order to be able to send email from your Mac.
in a terminal:
postfix start
Wednesday, May 28, 2008
Installing and setting up a fink installed MySQL with a non-default data directory
So I assume you have successfully executed: sudo fink install mysql
Create or edit /etc/my.cnf and add or change the keyword datadir to the directory you want e.g.
[mysqld]
datadir=/Volumes/another/directory
[mysqld_safe]
datadir=/Volumes/another/directory
During installation, Fink set up some files and directories in /sw/var/mysql. Copy the contents of this directory to your new directory e.g.
sudo cp -r /sw/var/mysql/* /Volumes/another/directory
Go to /Volumes/another/directory and set the owner of all contents to mysql e.g.
sudo chown -R mysql /Volumes/another/directory.
At this point you should be able to run 'sudo mysqld_safe.'
Saturday, May 17, 2008
fink Mysql on Macbook OSX 10.5 leopard
I installed mysql from fink and received some unwelcome news.
My-MacBook:~ me$ sudo mysqld_safe
Password:
chown: mysql: Invalid argument
Starting mysqld daemon with databases from /sw/var/mysql
STOPPING server from pid file /sw/var/mysql/My-MacBook.local.pid
080517 14:39:45 mysqld ended
After looking at /sw/var/mysql/My-MacBook.local.err, it seemed I was missing the user mysql. So I snooped around google and found the answer. Based on this, I executed the following commands:
sudo dscl localhost -create /Local/Default/Users/mysql
My-MacBook:var me$ sudo mysqld_safe Password:
chown: mysql: Invalid argument
Starting mysqld daemon with databases from /sw/var/mysql
STOPPING server from pid file /sw/var/mysql/My-MacBook.local.pid
080517 17:11:24 mysqld ended
This one was easy though. Just go to /sw/var and execute chown -R mysql mysql. You should be good to go from here. sudo mysqld_safe& should work just fine.
My-MacBook:~ me$ sudo mysqld_safe
Password:
chown: mysql: Invalid argument
Starting mysqld daemon with databases from /sw/var/mysql
STOPPING server from pid file /sw/var/mysql/My-MacBook.local.pid
080517 14:39:45 mysqld ended
After looking at /sw/var/mysql/My-MacBook.local.err, it seemed I was missing the user mysql. So I snooped around google and found the answer. Based on this, I executed the following commands:
sudo dscl localhost -create /Local/Default/Users/mysql
sudo dscl localhost -create /Local/Default/Users/mysql NFSHomeDirectory /var/emptyMy next attempt to start mysqld_safe gave me some more bad news:
sudo dscl localhost -create /Local/Default/Users/mysql Password '*'
sudo dscl localhost -create /Local/Default/Users/mysql PrimaryGroupID 74
sudo dscl localhost -create /Local/Default/Users/mysql RealName "MySQL Server"
sudo dscl localhost -create /Local/Default/Users/mysql UniqueID: 74
sudo dscl localhost -create /Local/Default/Users/mysql UserShell: /usr/bin/false
My-MacBook:var me$ sudo mysqld_safe Password:
chown: mysql: Invalid argument
Starting mysqld daemon with databases from /sw/var/mysql
STOPPING server from pid file /sw/var/mysql/My-MacBook.local.pid
080517 17:11:24 mysqld ended
This one was easy though. Just go to /sw/var and execute chown -R mysql mysql. You should be good to go from here. sudo mysqld_safe& should work just fine.
Wednesday, May 14, 2008
Adobe Flex license key Leopard OSX
If you ever receive a message like "License key is invalid" when you enter in your valid license
for Adobe Flex on OSX, try switching to an admin account. For some reason when you enter the license key into Flex Builder (or the Eclipse plug-in) under a non-admin account, you cannot 'activate' the installation.
for Adobe Flex on OSX, try switching to an admin account. For some reason when you enter the license key into Flex Builder (or the Eclipse plug-in) under a non-admin account, you cannot 'activate' the installation.
Saturday, May 10, 2008
gem install mysql mac osx leopard
gem install mysql -- --with-mysql-config=`which mysql_config`
Also you may need some additional hacking to get it all working.
Also you may need some additional hacking to get it all working.
Wednesday, March 19, 2008
Tuesday, March 11, 2008
Debugging ruby rails in production
Helpful little thing that helped me debug my ruby rails production system.
shell$ [RAILS_ROOT]/script/console production
So here you can invoke a model (e.g. User.new), call helper methods (UserHelper.authenticate(user, pass)), etc.
shell$ [RAILS_ROOT]/script/console production
So here you can invoke a model (e.g. User.new), call helper methods (UserHelper.authenticate(user, pass)), etc.
Thursday, March 6, 2008
Ruby Rails column type to MySQL datatype
lifted from PackT.
Migration column type... | Converts to MySQL field type... | Available options1 |
:binary | TINYBLOB, BLOB, MEDIUMBLOB, or LONGBLOB2 | :limit => 1 to 4294967296 (default = 65536)2 |
:boolean | TINYINT(1) | - |
:date | DATE | - |
:datetime | DATETIME | - |
:decimal | DECIMAL | :precision => 1 to 63 (default = 10) :scale => 0 to 30 (default = 0)3 |
:float | FLOAT | - |
:integer | INT | :limit => 1 to 11 (default = 11) |
:primary_key | INT(11) AUTO_INCREMENT PRIMARY KEY | - |
:string | VARCHAR | :limit => 1 to 255 (default = 255) |
:text | TINYTEXT, TEXT, MEDIUMTEXT, or LONGTEXT2 | :limit => 1 to 4294967296 (default = 65536)2 |
:time | TIME | - |
:timestamp | DATETIME | - |
Tuesday, March 4, 2008
Production Rails Database
To make a production version of a database defined in rails.
rake db:migrate RAILS_ENV="production"
rake db:migrate RAILS_ENV="production"
Monday, March 3, 2008
phpMyAdmin plug
Man... gotta use phpMyAdmin for looking at your MySQL database. On Mac use 'Fink Commander' and look for phpMyAdmin. Follow the configuration instructions here. In order for me to get it working, I had to set the following properties:
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';
Tuesday, February 26, 2008
Instance variable in viewer for ActionMailer
Using the ActionMailer in your Ruby on Rails application, I wanted to display a variable in the viewer. If the content_type is "text/html", the body needs to have the instance variable symbol e.g. body :var => var. In the viewer, you may reference this variable with <%= @var %>.
Thursday, February 14, 2008
svn checkout url
For some reason, I always have a tough time remembering how to check out code from an svn repository. So here it goes:
svn co svn+ssh://[user]@[server]/[path to project on svn server]
svn co svn+ssh://[user]@[server]/[path to project on svn server]
Sunday, February 10, 2008
Sharing OSX leopard folder and mounting it on Windows XP
So it shouldn't be that hard, but it took me about half an hour so I got to document it. I tried mounting a folder shared on my Leopard from an XP machine. This is finally how I got it done:
On Leopard:
On Leopard:
- In System Preferences, under Network, tab over to WINS and set the Workgroup to something like 'Mshome'
- In System Preferences, under Sharing, click options and check 'Share files and folders under SMB'
- Right click on 'My Computer', clicking on 'Map Network Drive'
- Click 'Browse', and you should see your Mac (for some reason your XP might not see the Mac right away, wait about 5 minutes)
Wednesday, February 6, 2008
Simple exporting of MySQL tables into a file
echo "select * from [table];" | mysql -u[user] -h[server] -p[password] [database] > [output_file]
Friday, February 1, 2008
Simple Ruby MySQL
To get the MySQL Ruby library to work as documented on troubleshooters, I had to add the following require statement:
require 'rubygems'
require 'mysql'
.
.
.
mysql.close()
require 'rubygems'
require 'mysql'
.
.
.
mysql.close()
Sunday, January 20, 2008
Thursday, January 17, 2008
Ruby Captcha
So I wanted to get a captcha rolling in Ruby on Rails. I decided to use recaptcha because Luis's research is so cool. The tutorial for Ruby recaptcha is fine, but I would have liked an explicit example of what would be in environment.rb.
Rails::Initializer.run do |config|
...
RCC_PUB = '...' #Public key from recaptcha registration
RCC_PRIV = '...' #Private key from recaptcha registration
end
Finally, I had to restart Webrick for those variables to take effect.
Rails::Initializer.run do |config|
...
RCC_PUB = '...' #Public key from recaptcha registration
RCC_PRIV = '...' #Private key from recaptcha registration
end
Finally, I had to restart Webrick for those variables to take effect.
Installing Mongrel on a Linux box
So I wanted to run Mongrel on a linux box in which I did not have root authority.
My configuration
My configuration
- ruby 1.8.5 (2006-08-25) [i386-linux]
- gem version 0.9.4
gem install mongrel -i [dir_you_can write_to] (You may have to run this twice if the first invocation gives an error)
You will see something like:
I picked 3. Hopefully this works with out a problem.
Select which gem to install for your platform (i386-linux)
1. mongrel 1.1.3 (java)
2. mongrel 1.1.3 (i386-mswin32)
3. mongrel 1.1.3 (ruby)
4. mongrel 1.1.2 (ruby)
5. mongrel 1.1.2 (mswin32)
6. mongrel 1.1.2 (java)
7. Skip this gem
8. Cancel installation
You will also need:gem install rails -i [dir_you_can write_to]
In the[dir_you_can write_to]
, you will find bin/mongrel_rails.
Go to your directory containing the rails application and run
[dir_you_can write_to]/bin/mongrel_rails.
After invoking this, I received the following error message:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:303:in `report_activate_error': Could not find RubyGem mongrel (> 0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:237:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:75:in `active_gem_with_options'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'
...
The solution for this is to set GEM_PATH like so:
export GEM_PATH=/non_default_gems_install/ruby_gems
Try running this again[dir_you_can write_to]/bin/mongrel_rails start -p 8000
Open a browser pointing it to server:8000 should display the rails application.
Wednesday, January 16, 2008
Getting Ruby on Rails up and running in Eclipse
So I'm running on a MacBook running Leopard and wanted to do some Ruby on Rails development using Eclipse. Here is what I did.
- Follow the tutorial for installing the base libraries for the following components
- Ruby
- RubyGems
- Ruby on Rails
- FastCGI
- You will need MySQL, but this tutorial is OSX specific
- MySQL Native Bindings
- Download and install Eclipse.
- Open Eclipse and install the following plugins.
- Aptana plugin
- Ruby Development Tools plugin (pick the release version) (OPTIONAL as of 6/9/2008)
- Subclipse plugin
- Somewhere in the process I ran into a problem involving Mylyn. Well go ahead and install that as well.
- Open Eclipse, open the Help drop down and click on Aptana Start Page. In the center column you will see the Aptana Ruby on Rails plugin. Go ahead and install it.
- Now you should easily be able to create a Rails project within Eclipse.
Subscribe to:
Posts (Atom)