Download Login to MySQL 2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Database wikipedia , lookup

Ingres (database) wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Open Database Connectivity wikipedia , lookup

PL/SQL wikipedia , lookup

SQL wikipedia , lookup

Clusterpoint wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Versant Object Database wikipedia , lookup

Transcript
DATABASE MANAGEMENT USING SQL (CIS 331)
MYSL ON CRUX (Part 2)
MySQL On Crux – Part II – The GUI Client
MySQL is the Structured Query Language processor that we will be using for this class.
MySQL has been set up for your use on the Baker Crux server. This is the same server
that hosts the student and faculty web sites. You will be working with the database in
two ways: from the command line and by using a front-end graphical application.
Instructions on accessing MySQL on Crux using the command line can be found in Part
I.
Accessing MySQL on Crux from a GUI Client
MySQL Command Center
MySQL Command Center is a graphical, front-end client for manipulating and reporting
of data in a My SQL database. MySQL Command Center is no longer supported by
MySQL and is being replaced by MySQLQuery Browser. It is presented here because it
is still available as a download from www.mysql.com, and is easy to use for queries.
Download and install MySQL Command Center according to the instructions provided
with the download.
Start MySQL Command Center.
Click on the Server icon
or select File/New from the menu.
Enter “Baker Crux Server” for Name.
Enter “crux.baker.edu” for the Host Name.
The User name is your baker User ID.
The Password is your MySQL password (First and Last initial and last 6 digits of your
UIN)
If you check on the “Prompt for Password” box, you will be prompted for the password
every time you start MySQL CC. It is more convenient to leave the box unchecked.
Leave all other entries default.
Click “Add” at the bottom of the screen. If you entered your User Name and Password
correctly, There will be a message at the bottom left stating that the connection was
added correctly.
Double-Click on Baker Crux Server in the left frame to expand it. Do the same with the
Databases folder, and your database name. Highlight Tables. If there are tables already
in your database, they would be listed in the right frame.
Notice the bottom menu and the row of icons directly below that. These are both
“context-sensitive” menus. Depending on what view is displayed, there will be different
choices. The default view is the Console manager, so the choices have to do with actions
you can accomplish from this view.
Running a query in MySQL CC
Make sure that Tables is highlighted in the left frame.
Click on the SQL icon
or use File/Query from the menu.
This is the Query view. Notice that you have more icons and menu choices than in the
Console manager view.
There are three parts to this view that you will use, although only two are visible now.
The top part is where you enter the query. When the query is executed, the results, if any
will be displayed in the center section. At the bottom is the Message area. Success and
error messages are both displayed in this area.
Navigate to the folder where you unzipped the SQL script files to bu clicking the folder
icon
or using File/Open from the menu.
Select a file by double-clicking on the name or single-clicking on the name and then
clicking Open. For this example, choose MySQL-Alexamara.sql. This script file will
create the Alexamara Marina Group tables and populate them with records.
Notice that the SQL query statements are copied into the upper area of the Query view.
You can also type queries here, but opening a pre-existing file or even copying and
pasting text is much easier.
Now the queries in the file are ready to be executed. This is done by clicking on the
Execute icon
or selecting Query/Execute from the Menu.
There is now a middle part showing in the Query view for the results of the query.
Because this query created and populated tables, there are no results, so the results area is
blank. In the message area, you will see one message for each of the queries in the script,
either success messages or error messages.
Close out the Query view and return to the Console Manager view. Notice that even
though you created the tables, there are none showing. You must refresh the tables after
each query that modifies them to see the results. There are two refresh icons. The
is the page refresh. The Table refresh icon
familiar looking one
select to refresh the view of the tables.
is the one you
These are the tables associated with the Alexamara Marina Group “database”.
Remember that there can only be one database per user on Crux. What is referred to in
the textbooks as the Premiere, Henry, and Alexamara databases are just an associated
collection of tables. Notice that if you create the Henry Books tables that in this view,
they are mixed up with the Alexamara tables.
You can now run queries against the database and any of the tables by entering individual
or multiple queries in the Query view and executing them.
There are many more features to MySQL Control Center, but since it is no longer
supported by MySQL and there is no User’s manual, you must experiment to learn them.
MySQL Query Browser
MySQL Query Browser is a graphical, front-end client for manipulating and reporting of
data in a My SQL database. MySQL Query Browser is replacing MySQL Command
Center. There is a downloadable User’s manual in both PDF and HTML format.
Download and install MySQL Query Browser according to the instructions provided with
the download.
Start MySQL Command Center.
Enter “crux.baker.edu” for Server Host.
Username is your Baker ID.
Password is your MySQL password (First and last initial and last 6 digits of your UIN).
Enter your MySQL database name for the Default Schema. By entering a default
Schema, you do not have to enter the USE database command each time you launch
MySQL Query Browser.
Click OK.
There are three areas of the screen that you will use right away. At the top is the Query
Edit window or Results Window, depending on the tab selected. Select View/Maximize
Query Edit from the menu to give yourself a little larger area in which to work with.
In the right frame is the view or Schemata of the database. If you have tables already in
your database, you can expand the Schemata to see the tables. At the very bottom of the
screen is where messages will appear.
Using File/Open Script from the menu, navigate to the directory where you have
unzipped the SQL script files. Select one of the files that will create tables that are not in
your database yet. The SQL script will open in the Query Edit window with a new
“Script” tab created. Notice that when the Script tab is selected, there is a new set of
context-sensitive icons above it. These icons allow you to start, stop, or even single-step
the script processing.
Click the Execute Icon
to run the script. There will be a “Processing” message at
the bottom. Any error messages will also appear at the bottom of the screen. If the table
creation script runs OK, you will see the Schemata on the right expand to include the new
tables. Expanding the tables in the Schemata will show you the column names and the
keys.
Once the table creation query has run successfully, you can close the Script tabsheet by
right-clicking the tab.
To run an individual query against a table, enter a query, such as SELECT * FROM
MARINA (to see all the records in the Marina table), in the Query Edit window under the
Resultset1 tab. Click the Execute Icon.
You will now see the query, the results, and the message indicating success.
One useful feature of MySQL Query Browser is the Built-in Syntax help. By expanding
and clicking on subjects in the lower right frame, syntax help pops up in the results area.
You can store the connection information by going to tools/Save Current Connection on
the menu. By storing the connection, all you have to do each time you launch MySQL
Query Builder is enter your password.
To explore further features of MySQL Query Browser, see the User’s manual or the
many areas under the Help menu.
Submitted by Phil Grimes/OL; 2/05
dmm:022205
Cis331-7