Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Thursday, June 6, 2013

MySQL on Macbook

My wife wanted to set up an environment so that she could practice her sql skills.  After a bit of research, I decided to give MySQL a try.  Here are my notes on how it went.

Step 1. Download the software.
http://dev.mysql.com/downloads/mysql/
I chose the 64 bit DMG archive for Mac version to install.  Before the download started I had to jump through a few hoops.  First, I had to register to get a new oracle account.  This sign up was pretty painful.  I had to provide my name, full address, phone number, and a complicated password.  As usual, I entered a password that I will surely forget by the next time I am asked for it.  I then had to fill out a survey about my job, what I will use the software for and some other questions.  This was a bit off-putting, but in the end, I finally downloaded the file.

Step 2. Installation.
I clicked on the downloaded dmg file and then the pkg file which started the installation process.  I was told that the install would use 680.9 MB of space, which seems a bit high.  The software was installed in less than a minute.  I also installed the MySQLStartupItem.pkg, but I'm not sure what that is.  I finally installed the MySQL.prefPane, which gives a GUI (placed as an icon in system preferences) so that you can easily start the MySQL server.

Step 3. Hello world.
I wanted to do the basic operations with a database to make sure that I had installed everything ok.  In the programming world, when you start working with a new language, you would try to write some code, compile it, and then output the results.  Typically, you make the program say, "hello world".  I think I got my database to say "Hello World" with the following commands:

a. First, I created a database:
mysql> CREATE DATABASE testdb;
Query OK, 1 row affected (0.00 sec)
b. I confirmed that my database was created by showing them:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
c. I then told mysql to use the database I just created.
mysql> use testdb;
Database changed
d. I created a table.
mysql> create table phrase_table ( 
-> words char(25)
-> );
Query OK, 0 rows affected (0.02 sec)
e. I added one row. It has one column called words and the phrase "Hello World".
mysql> insert into phrase_table (words) values("Hello World");
Query OK, 1 row affected (0.00 sec)
f. I finally selected all rows from my table to get the program to say "Hello World".
mysql> select * from phrase_table;
+-------------+
| words |
+-------------+
| Hello World |
+-------------+
1 row in set (0.00 sec)
e. Done. I got the basic operations to work. This link was pretty helpful. http://www.mysqltutorial.org/basic-mysql-tutorial.aspx