My kung-f00 is better than yours!

How to successfully deploy a fully working php/symfony environment in Snow Leopard II: MySQL

Posted: March 1st, 2010 | Author: alej | Filed under: tutorials | Tags: , , | No Comments »

Let’s start our journey the easy way: with MySQL. First of all we need to download a copy of the MySQL Community Server, preferably in .dmg format, from here. For this tutorial I have selected this one: Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive, the first one. To proceed, we have to register or press the “No thanks” link under the form and select a mirror.

Once we have the dmg file, we mount it (by double clicking it..) and we could see the contents of the package:

To actually install the application, we have to double click the first .pkg file, named something like “mysql-5.1.44-osx10.6-x86_64.pkg” and proceed through the installation. We may be asked our password for administrative purposes.

Now that we have installed mysql, we are provided three ways to start the server:

  1. The ugly command line, with mysqladmin
  2. Autostart the server, installing the provided MySQLStartupItem.pkg, but we want to have more control than that..
  3. And by an individual control “switch” in the preferences panel. Let’s do that, so we are able to start/stop the server whenever we want in an easy way!

So double click in the MySQL.prefPane file and install the panel only for your user (you don’t have a sister who likes programming, do you?). Now, when we want to manipulate the state of the mysql server, we just have to go to this panel and turn it on or off (I personally do it with +space and then typing mysql).

Mind that normally, when manipulating the state of the mysql server we will be requiered administrative priviledges, so we will be asked for our password quite often.

And that’s it, we have installed MySQL Server in our mac… but beware, as the default installation doesn’t provide a password for the root user!

To do so, we need to use the terminal, setting the mysql installation dir in our path and setting a new password for root.

$ echo ‘PATH=$PATH:/usr/local/mysql/bin’ >> ~/.bash_profile
Restart the terminal and then:

$ mysql_secure_installation
Press enter, as root does not have any password right now
Press enter, so we are asked for a new root password

Enter the new root password
Press enter, so we remove the anonymous user

Press enter, so we disallow root login remotely
Press enter, so we remove the test database
Press enter, to reload the privilege tables
And we’re done!

You could test your freshly installed copy of mysql with mysql -uroot -p

Links:
If you run into trouble, maybe this apple guide could help you.