Installing MySQL and phpMyAdmin for web development on a Mac OS X 10.9, 10.8, 10.7, 10.6

This is a simple guide on installing a must have SQL database engine for web development. It is often used at the beginning of the journey and I did not find a good guide for it. That made me make myself one and share with others. Hope somebody would benefit from it.






First we need to setup the MySQL community edition (latest or not depending on your requirements). It's possible to download it here: http://dev.mysql.com/downloads/mysql/

It comes in form of a .pkg installer file. It is advised to install it as follows by using default settings. Installation is pretty straightforward. Just click next and agree several times...
This will add a service of MySQL to your system. Nothing more. To interact with it you need either to use SQL console (in case you know SQL) or install something like phpMyAdmin to interact with it. Your pkg installer installs a useful enough Preference Panel switch by default.
There you can have it basically configured. Only two basic options persist. Either to run the service on startup or start/stop service button.
Go ahead and start a service for farther interaction:
It is possible to now test your MySQL version by typing a terminal command:
/usr/local/mysql/bin/mysql -v
Good idea would be to add a path to your mysql executable to system path in your bash config. So you could type just "mysql" without specifying a path. To do so append this line to your ~/.bashrc_profile:
export PATH="/usr/local/mysql/bin:$PATH"
Either restart console or do source ~/.bash_profile to update your current environment.
It is now possible to do:
mysql -v
Note you do not have to specify a path to it any more.

Stoping at this no more farther let's finish configuring mysql by adding at least one main user/password and disabling defaults. There is a handy config script for this:
sudo mysql_secure_installation
Just execute this and follow up the steps widely described to you there. That's it you can now use MySQL on your system.

Let's go ahead and make a UI for ourselves by installing phpMyAdmin. Basically it's a utility that runs on your mac's built in Apache server (make sure it is running) and provides you an ability to manage your SQL databases through a handy web UI.

here you need to download a http://www.phpmyadmin.net/home_page/downloads.php latest version of the phpMyAdmin.
You will get yourself an archive version of this PHP application. that's basically all you need to know about it.
You also need to have apache running on your MAC. Make sure you do. zThere are many guides on it. Basically you need to have your computer outputting something in your web browser in case of typing localhost in your address line:
With this in mind you also need to have PHP enabled in your apache config. There are guides on that too. Enough of precautions and let's move farther with our straightforward install:
Time to place our unpacked folder contents into ~/Sites folder. It is advised to rename it into 'myadmin' to follow along with me.
This will bring you ability to type:
http://localhost/~your_username/myadmin/setup/ or either http://localhost/myadmin/setup/, depending on your apache configuration.
This will show up something similar to this:
Click New Server button and configure your newly installed MySQL server, so phpMyAdmin would be able to use it.
Fill in only username root and your root password, leaving all the other fields intact. (with default settings). You hopefully remember specifying a password for root in the initial MySQL server configuration step?
Switch to the Authentication tab and enter them.
Now you are able to manage your MySQL databases through a web UI using phpMyAdmin
Type in the address like: http://localhost/~username/myadmin/

Here you go... Please comment in case you have found it useful. I will know my time writing this was not wasted. thank you!

Comments

  1. The (only) reason I am still in the MySQL camp after thirteen years is that every time I try to install PostGreSQL on Debian Linux and use it, it feels like an exercise in masochism. The environment is endlessly pedantic and bureaucratic with misleading error messages that would make a K&R C compiler blush. Thanks.

    Steve R.

    ReplyDelete

Post a Comment

Popular posts from this blog

Django: Resetting Passwords (with internal tools)

Time Capsule for $25

Vagrant error: * Unknown configuration section 'hostmanager'.