Showing posts with label Lion Server. Show all posts
Showing posts with label Lion Server. Show all posts

Sunday, April 1, 2012

How to install MySQL 5.5 on Mac OS X 10.7 Lion


This may not be obvious, but on the new Macs that ship with Lion, you can use the MySQL 5.5 64-bit dmg installer. It works perfectly on Lion, even though the MySQL site (still, at the time of this writing) says Mac OS X 10.6 Snow Leopard. You can use the Preference Pane to stop and start MySQL.

Now after MySQL 5.5 is running, strangely enough, you cannot simply launch terminal and type
mysql -u root
Bash will complain that it can’t find mysql. So we have to help it like so:

1. Use your favorite text editor to edit the file
/Users/%yourname%/.bash_profile
If this file doesn’t exist you can create it.

2. Add the following line to your .bash_profile
export PATH=$PATH:/usr/local/mysql/bin
and save the file. Be careful editing this file exactly as above. You can render terminal unable to find all your programs if you break your $PATH.

3. Quit and relaunch terminal, or type
source ~/.bash_profle
and hit return to reload the changes in your profile.

4. Check your $PATH by typing
echo $PATH
and pressing return. You should see something like this
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin
5. Now you should be able to run
mysql -u root
which means there is no root password by default!

6. Run this next, at the mysql prompt
GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'your_password_here' WITH GRANT OPTION;
This is how to secure your root user login.

Now, for PHP to use this connection I had to tweak my system as shown below:

1. Run phpinfo() and check out the path PHP is trying to use for mysql.sock. On my new Mac Mini, it was
/var/mysql/mysql.sock
2. From terminal, I did
sudo find / -name mysql.sock -print
3. The critical line of output shows that MySQL 5.5 installs the sock to
/private/tmp/mysql.sock
4. Now we need to create a symlink for PHP to be able to access the mysql.sock. Trouble is if you try it you’ll get an error because /var/mysql doesn’t exist. So next, do
sudo mkdir /var/mysql
5. Finally, do this
sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

Saturday, March 31, 2012

Configuring RAID 1 (Mirroring) on the 2011 Mac Mini Server



  1. When booting the Mac Mini for the 1st time, hold the "T" key down to force the unit into Target Disk Mode 
  2. Connect a laptop via Firewire 800 cable 
  3. Open Disk Utility on the laptop 
  4. Select the primary Macintosh HD mounted from the Mac Mini on your laptop HD in Disk Utility 
  5. Select New Image and change the type to Read Only and the save destination to your laptop's Desktop and start creating the image (approx 5-7 minutes) 
  6. When finished imaging, select each of the 500GB internal HD's and Erase leaving the name as the default 
  7. Select RAID and drag each of the Untitled HD's into the RAID window 
  8. Press the Options button at the bottom and put a check in the "Automatically rebuild RAID mirror sets" and leave the RAID Block Size: at 32K 
  9. Press Create RAID and wait till finished (~30 seconds) 
  10. Select Images from the top pull-down and then Scan Image of Restore… 
  11. Select the image of the Macintosh HD from step 4 on the Desktop to prepare it for the restore 
  12. Press Restore at the top right and drag the new RAID volume into the Destination box 
  13. Select the Browse… button to the right of the Source and select the Macintosh HD image you just scanned for restore 
  14. Select Restore and press Continue at the warning box 
  15. When the restore is finished, quit Disk Utility and drag the Macintosh HD Firewire mount to the trash to disconnect it from Target Disk Mode 
  16. Push the power button on the Mac Mini Server to shut it off and pull off the Firewire 800 cable 
  17. Restart the Mac Mini Server and begin the Setup Assistant process