Quantcast
Viewing latest article 4
Browse Latest Browse All 10

Environment Consistency – MySQL (Apple Macintosh)

We need to make our life easier by creating consistency for every machine. What this means is every machine you try to use, whether it be yours or your colleagues, the environment will be the same when you sit down to help them with something. This is very important if you’re a Development Manager and you’re trying to help one of your staff.

This is one of several posts in regards to this subject.

I really don’t use MySQL too much.  At work, I have Oracle and Sybase.  But I think I’m going to use it in the example code that I post later.  Because we’ll be using Hibernate, for the most part, it really doesn’t matter.  Hibernate hides the nuances of each type of database from us (for the most part).  Anyway, the real reason has to do with our earlier PHP post and a post about WordPress that I’ll be making later.  ]

Here we’re going to install MySQL for the Macintosh.  We’ll go back and do it for Windows in a later post.

First off, we need the binary.  We’ll go to the MySQL website to download the 5.1 MySQL version file called “mysql-5.1.41-osx10.5-x86.dmg”.  After we’ve gotten that downloaded double click it and we’ll see this window after the image has been mounted:

Now click on the icon for “mysql-5.1.41-osx10.5-x86.pkg” and you should see this window:

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Welcome Screen

MySQL 5.1.41 Installer Welcome Screen

click “Continue”

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Important Information

MySQL 5.1.41 Installer Important Information

click “Continue”

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Software License Agreement

MySQL 5.1.41 Installer Software License Agreement

click “Continue” and a window will drop down

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Agree to Software

MySQL 5.1.41 Installer Agree to Software

click “Agree”

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Select A Destination

MySQL 5.1.41 Installer Select A Destination

click “Continue”

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Confirm Install Location

MySQL 5.1.41 Installer Confirm Install Location

click “Install”

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Enter Password

MySQL 5.1.41 Installer Enter Password

you’ll need to type in your password so that you’ll have permission to install the software and after you’ve done that, the software should start to install

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Installing

MySQL 5.1.41 Installer Installing

and when it’s done you’ll see this window:

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Installer Successful Install

MySQL 5.1.41 Installer Successful Install

Now you have the MySQL database installed.  But you don’t want to have to start it by hand every time your system boots.  You’d rather it start automatically for you.  We have an app for that. Image may be NSFW.
Clik here to view.
:)
  Go back to this window

and this time click on “MySqlStartupItem.pkg” and you’ll see this window

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Startup Item Installer Welcome Screen

MySQL 5.1.41 Startup Item Installer Welcome Screen

click Continue

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Startup Item Installer Welcome Screen

MySQL 5.1.41 Startup Item Installer Welcome Screen

click Continue

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Startup Item Installer Select Destination

MySQL 5.1.41 Startup Item Installer Select Destination

click Continue

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Startup Item Installer Confirm Destination

MySQL 5.1.41 Startup Item Installer Confirm Destination

click Install

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Startup Item Installer Successful Install

MySQL 5.1.41 Startup Item Installer Successful Install

and you’re done.  Click Close.

We could go through the process of starting MySQL by hand but it’s just as easy to reboot our machine.  That way we’ll know it starts automatically for us as well.  So, reboot!

After you’ve rebooted, let’s start up a “Terminal” window.  Once that’s done, type in the following command:

ps -aef | grep mysql

and you should see results that look similar to this:

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Confirm Install

MySQL 5.1.41 Confirm Install

MySQL doesn’t have a Graphical User Interface so a lot of what we’ll be doing is via the command line.  Because of this, we need to put the /usr/local/mysql/bin in our PATH environment to make life easier for us.  We do this by cd-ing to the /etc directory and then editing the profile file using vi (via sudo).  We’ll be executing these commands:

cd /etc
sudo vi profile

and our window should look like this:

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Edit /etc/profile

MySQL 5.1.41 Edit /etc/profile

In this file, you should see a line that says PATH.  You want to put the line “/usr/local/mysql/bin:” right after the = sign of that line.  You should see a window that looks like this:

Save it and end your Terminal session and start a new one so that this will take effect for you.

Now that the MySQL server is started, we need to get in and do some things for security reasons.  The server starts with no password for the “root” user and it also has an anonymous account.  We need to fix those issues.  So we start up a “Terminal” window again and we’ll be executing the following command to get us into the MySQL interface:

mysql -u root

and the first thing we’re going to do is delete the anonymous users by running this command:

DELETE FROM mysql.user WHERE user=”;

your window will look like this:

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Delete Anonymous Users

MySQL 5.1.41 Delete Anonymous Users

And finally we need to get in and change the password for our root user.  Start up a “Terminal” window and get in MySQL by this command:

mysql -u root

then run the following command

UPDATE mysql.user SET password = PASSWORD=(‘xxxxxx’);

Be aware here though.  First off, you’re changing ALL the passwords of ALL the users in your database.  This is a fresh install so that’s OK but if for some reason you’re following this and it’s not a fresh install then be aware.  Secondly, I’m changing the password to ‘xxxxxx’, you’ll want to change it to something real.

How will we know that our password has been changed?  We now have to add the “-p” argument when we try to get into MySQL from now on else we can’t get in.  So we’ll be executing a command like this

mysql -u root -p

and the server will now ask you for the password when you try to get into your server.

The window for this will look like the following for these commands:

Image may be NSFW.
Clik here to view.
MySQL 5.1.41 Change root Password

MySQL 5.1.41 Change root Password

We now have MySQL installed on our Apple Macintosh.


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 4
Browse Latest Browse All 10

Trending Articles