Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 1/24 
 
  
CSCI 201 Lab 7 
Setting up MySQL 
Any enterprise CEO really ought to be able to ask a question that involves connecting data across the organization, 
be able to run a company effectively, and especially to be able to respond to unexpected events. Most 
organizations are missing this ability to connect all the data together. - Tim Berners-Lee 
If you are running OSX, skip down a couple of pages to find your installation 
instructions.  
 
Introduction 
This lab will introduce you to MySQL.  Before being able to run the DBMS, we will need to install 
it.  There is another tool that helps us to visualize the database called MySQL Workbench that 
we will also install.  By the end of this lab, you will have a working version of MySQL and be able 
to insert and select from a database you have created. 
 
Part 1.1 – Download and Installation in Windows 
Windows 7/8/8.1/10 
Go to http://dev.mysql.com/downloads/windows/installer/ 
Click either the first or second download. It doesn’t matter which. 
 
You don’t need to sign up or log-in. Just say no thanks. 
 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 2/24 
 
  
THE INSTALLER WILL ASK YOU TO SAVE A TEMPORARY PASSWORD. SAY YES! 
Accept the license agreement.
 
Choose Developer Default. This will install everything we need – and more. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 3/24 
 
  
You may get a warning similar to this. Just make sure they aren’t related to Java.
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 4/24 
 
  
Press ‘Execute’ and wait for everything to finish.
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 5/24 
 
  
Press Next > 
 
Leave everything as-is. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 6/24 
 
  
You do need to create a user account. Make the username and password 'root'. 
If you do not do this the next lab will be unnecessarily difficult. You will be using 
this username and password for all class SQL labs/projects. Yes, this is generally 
a bad idea in real life applications, but we will gloss over this for the sake of 
learning SQL. 
 
After this is done, press Next > 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 7/24 
 
  
Press ‘Execute’, and wait for everything to finish. 
 
Press Next > 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 8/24 
 
  
Enter the username and password. And check the connection. Press Next > 
 
Press ‘Execute’ and wait for it to finish. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 9/24 
 
  
Press Next > 
 
All done! MySQL is installed. Go ahead and start MySQL Workbench. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 10/24 
 
  
Part 1.2 - Download and Installation in OSX 
Go to 
http://dev.mysql.com/downloads/mysql/ 
Select a download for your machine. 
Do not download the .tar file!!! Download the .dmg file (yes it is bigger!) 
 
Continue… 
THE INSTALLER WILL ASK YOU TO SAVE A TEMPORARY PASSWORD. SAY YES! 
 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 11/24 
 
  
 
 
Continue 
 
  
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 12/24 
 
  
Select a destination, then install. 
 
Close 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 13/24 
 
  
 
Now, start the MySQL server by going to System Properties. 
 
Select MySql and this window will appear. 
 
  
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 14/24 
 
  
Press ‘Start MySQL Server’. The server will then start. 
 
  
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 15/24 
 
  
Now, go to  
http://dev.mysql.com/downloads/workbench/  
 
Download and Install. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 16/24 
 
  
Now, launch MySQLWorkbench.
 
  
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 17/24 
 
  
Part 2 - MySQL Workbench 
On Windows, you will see a single connection. For Mac, you won’t have any 
connections yet. Press the plus button to make a new  
 
For Windows, Right-click and select ‘Edit Connection…’ 
For Mac, press ‘New’. 
Set the connection name to something a bit more meaningful such as My201SQL. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 18/24 
 
  
Now double-click the grey box to open the editor 
 
Enter your password you set earlier. 
 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 19/24 
 
  
You will see the following page. 
 
Click the highlighted button to create a new schema. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 20/24 
 
  
Enter a name for the schema. 
 
Once you press ‘Apply’ a new window will pop up. Press ‘Apply’. This will create 
the new schema. 
 
 
  
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 21/24 
 
  
Double-click the schema to select it. 
 
Click the highlighted button to create a new table. 
 
Go ahead and name the table. Also insert two columns. 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 22/24 
 
  
Name the columns ‘name’ and ‘created’. 
The name column will correspond to the name of the resource. 
The created column will correspond to the number of that resource that has been 
created. 
 
Press ‘Apply’ and you will see another window like before. Once again, hit ‘Apply’. 
 
 
 
 
 
 
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 23/24 
 
  
This new table will be generated. Click the highlighted button to view the new 
table. 
 
The table is empty. We can type values in manually, but we should have Java code 
do the work for us. 
 
 
  
 CSCI 201 Lab 7 
 Prof. Jeffrey Miller 
 24/24 
 
  
Expand on This 
Yup, there is an expansion this week!  
Create a new table, and name it factoryresources. Look in the factory.txt file in your Factory 
project and duplicate the information into the factoryresources table in the mySQL workbench. 
You don't have to write any Java code, just try to get used to using mySQL and looking up 
instructions on how to do things on the internet.  
This doesn't mean that you will not be coding at all, you will need to write some SQL code. Try 
looking though the resource below, and pay close attention to the INSERT and SELECT 
statements. If you don't end up using these statements there are other ways to do this.  
http://www.w3schools.com/sql/ 
Hint: Once you have created a new table, there should be a window up top that allows you to 
enter and execute SQL code. You can run it by clicking the little lightning button. If you want 
default values to appear on the table, there will be one additional step to get an extra row to 
appear.