Database Concepts and MySQL

From Notes

Jump to: navigation, search

These notes and readings are meant to provide some background about databases for those who have little or no experience in that area. The focus will be practical -- that is, the goal is to be able to set up and use a simple MySQL database in a simple Web application.

Contents

Database Concepts

  • Database Fundamentals: These notes summarize fundamental database concepts, including some of the underlying mathematics. (Just skip the stuff on the Entity-Relationship models.)
  • Database Concepts, SQL, MySQL: This tutorial provides a practical introduction to databases, introduces the main SQL commands, and provides a hands-on example of creating and manipulating a simple database in MySQL. (Skip over the stuff on normal forms. It's not particularly clear or useful for our purposes.)


MySQL Tutorial

  • Sun MySQL Tutorial: This is a MySQL tutorial from Sun Microsystems. It explains and illustrates the various commands. Work through portions of this tutorial.

The examples in this tutorial use a command-line interface. This is useful to know even though we will mostly be using PhPMyAdmin. It would be useful if you try the commands and follow through the tutorial.

Connecting to the MySQL Server

In order to try the examples described in these tutorials, you will have to connect to your MySQL server. This section describes how you would do that.

On the Macintosh

In the default MAMP configuration the MySQL server is not protected by a password. So, once you have started MAMP, you can connect to the MySQL server, with the default user name, by using the following command:

username$/Applications/MAMP/Library/bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.1.37 Source distribution

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

mysql> 

To exit the mysql prompt, type exit or Ctrl-C.

On Windows

Running MySQL server with EasyPHP

Goto Start - Programs - EasyPHP and Click on EasyPHP.exe. This will start the Apache webserver, PHP and MySQL automatically. You can go to phpmyadmin at http://127.0.0.1/home/mysql/

Run the following command in Start-->Run (include the quotes) to launch the mysql command line.

"C:\Program Files\EasyPHP5.3.0\mysql\bin\mysql.exe" -uroot -p

When successful you will get the following text on a new command window. If you have set a password enter it here, if not simply press enter to proceed.

 Enter password:
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 8
 Server version: 5.1.37-community-log MySQL Community Server (GPL)
 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 mysql>
For WAMP users

Once you have the WAMP services running, simply left click, on the WAMP icon in the system tray and go Mysql in the menu and select Mysql console to launch the Mysql terminal. If you have a password set enter it here, if not simply press enter to proceed.


On the CPSC Department's Server

You can launch the phpmyadmin setting for the database server on storage1.cs.trincoll.edu by going to http://storage1.cs.trincoll.edu/phpmyadmin.

You can launch the mysql command locally or through a ssh connection to any of the terminals in the lab. To connect to the database server:

 mysql -h storage1.cs.trincoll.edu -u -p .

Using PhPMyAdmin

PhpMyAdmin comes installed with our WAMP/MAMP platforms. It provides a web interface to the MySQL server. You can use it to do everything that we just did from the command line but using a more familiar interface.

On the Macintosh

To start PhPMyAdmin on the Macintosh (with the default MAMP configuration),use the following URL: [1] and select the PhpMyAdmin tab.

Personal tools
NSF K-12