21
1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip http://dev.mysql.com/ MySQL GUI Tools mysql-gui-tools-noinstall-5.0-r12-win32.zip http://dev.mysql.com/ Unzip both directly to the root drive using the folder names. This should create the following: C:\mysql-5.0.51b-win32 C:\MySQL GUI Tools 5.0

MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

  • Upload
    vocong

  • View
    252

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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

Page 2: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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.

Page 3: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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

Page 4: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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

Page 5: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

5

Enter the following command to start the service:

net start mysql

Page 6: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

6

To stop MySQL and remove the service:

Enter the following command to stop the service:

net stop mysql

Page 7: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

7

Enter the following command to remove the service:

mysqld-nt -- remove

Page 8: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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.

Page 9: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

9

You should see the following.

Page 10: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

10

Change Options

Select Tools | Options…

Page 11: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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);

Page 12: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

12

Execute the Script.

Select the Script, then Select Script | Execute Selection

You should see the table in the Schemata View.

Page 13: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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

Page 14: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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;

Page 15: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

15

Execute the Script.

You should see the following.

Page 16: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

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';

Page 17: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

17

Execute the Script.

Select the Script, then Select Script | Execute Selection

Page 18: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

18

Save the Script

Select File | Save As…

Page 19: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

19

Name the file.

Page 20: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

20

Test the GRANT

Close the MySQL Query Browser and reopen.

Login with user1 and pass1

Page 21: MySQL and Query Browser Quick Start and Query... · 1 Using MySQL and MySQL GUI Tools on Windows XP Professional Version 2002 Service Pack 2 Download and Install MySQL mysql-noinstall-5.0.51b-win32.zip

21

Enter the following and Execute the Script. The DROP should not be allowed.

-- Drop Table petDROP TABLE pet;