View
254
Download
0
Category
Preview:
Citation preview
1
Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002Service Pack 2
Download and Install
MySQLmysql-noinstall-5.0.51b-win32.ziphttp://dev.mysql.com/
MySQL GUI Toolsmysql-gui-tools-noinstall-5.0-r12-win32.ziphttp://dev.mysql.com/
Unzip both directly to the root drive using the folder names. This should create thefollowing:
C:\mysql-5.0.51b-win32
C:\MySQL GUI Tools 5.0
2
Create Environment Variables
Create an environment variable called MYSQL_HOME and point to where MySQL isinstalled. The default location is:
C:\mysql-5.0.51b-win32
Update the PATH variable to include %MYSQL_HOME%\bin.
3
Start the MySQL Server
You can also create a Shortcut on your Desktop to make this easier.
Open a cmd prompt.
Enter the following command to install MySQL as a service:
mysqld-nt --install
4
If you have errors, try renaming the MySQL folder to:
C:\mysql
Update the MYSQL_HOME environment variable.
If you are still have errors, try to start MySQL with the following:
Open a cmd prompt.
Enter the following command to install MySQL as a service:
mysqld-nt --console
5
Enter the following command to start the service:
net start mysql
6
To stop MySQL and remove the service:
Enter the following command to stop the service:
net stop mysql
7
Enter the following command to remove the service:
mysqld-nt -- remove
8
Start MySQL Query Browser
You can also create a Shortcut on your Desktop to make this easier.
Run the following command:
C:\MySQL GUI Tools 5.0\MySQLQueryBrowser.exe
Enter train for the Default Schema and leave the Passowrd blank. This is the defaultpassword for root:
Click OK and you will be prompted to create the Schema.
9
You should see the following.
10
Change Options
Select Tools | Options…
11
Data Definition Language (DDL)
CREATE TABLE
Enter the following:
-- Create Table pet
CREATE TABLE pet(id INTEGER NOT NULL PRIMARY KEY,name VARCHAR(35),price DECIMAL(5,2),birth_date DATE);
12
Execute the Script.
Select the Script, then Select Script | Execute Selection
You should see the table in the Schemata View.
13
Data Manipulation Language (DML)
INSERT
Enter the following:
-- Insert a row into petINSERT INTO pet(id,name,price,birth_date)VALUES(1,'Fido',125.99,'2005-10-10');
Execute the Script.
Select the Script, then Select Script | Execute Selection
14
SELECT
Create a Resultset Tab by selecting File | New Resultset Tab
Enter the following in the Query View:
-- Select the rows from petSELECT * FROM pet;
15
Execute the Script.
You should see the following.
16
Data Control Language (DCL)
First, create a new user.
-- Create userCREATE USER 'user1'@'localhost'IDENTIFIED BY 'pass1';
GRANT
Enter the following:
-- Grant privilegeGRANT SELECT,INSERTON TABLE petTO 'user1'@'localhost';
17
Execute the Script.
Select the Script, then Select Script | Execute Selection
18
Save the Script
Select File | Save As…
19
Name the file.
20
Test the GRANT
Close the MySQL Query Browser and reopen.
Login with user1 and pass1
21
Enter the following and Execute the Script. The DROP should not be allowed.
-- Drop Table petDROP TABLE pet;
Recommended