Skip to content

Using our MySQL Instance

bwanicur edited this page Apr 2, 2012 · 8 revisions

After you have completed installing the MySQL (https://github.com/bwanicur/IntroToSQL/wiki/Installing-MySQL), you will now have MySQL instance on your computer. We call it an "instance" because it is possible to have more than one of these installed.

Using the MAMP/WAMP Interface

After starting the MAMP/WAMP program, it will open it's "start page" in your default browser. This start page will have several tabs. One of the is called "PHPMyAdmin".

PHPMyAdmin is a program that let's you manipulate MySQL using a GUI (Graphical User Interface). It saves you from having to learn SQL. We want to learn SQL, so we are only interested in it's "SQL" tab. This tab should take you to a screen with a big white field where you can type raw SQL. The other tabs of PHPMyAdmin give you ways to create tables, query tables, etc... If you want to learn about SQL, you will ignore all of these other tabs.

I suggest you use a text editor and cut and paste your SQL commands into this field. Many text editors have nice syntax highlighting features that this field in PHPMyAdmin does not provide.

Optional: Using The Command Line "mysql" Program

For those of you that would like to run your SQL commands inside of terminal (mac) or a console emulator (on windows), please mention this at the first class. MAMP/WAMP installs a command-line program at the following location: <install location>/Library/bin/mysql. Here is an example on my computer: /Applications/MAMP/Library/bin/mysql -u root -p. Running this in terminal will execute the mysql command line client with the "root" user -u, and it will ask me for the password -p. For MAMP/WAMP the "root" user has "root" as the password. Once you have entered the password, you should see something like this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.5.9 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

The mysql> prompt now informs you that you are inside the mysql program. You can execute SQL commands here. Again, I recommend you have a text editor handy. Typing multi-line SQL commands into console can be a burden.