MySQL Installation Guide Step1- Install MySQL

Post on 21-Apr-2022

36 views 0 download

Transcript of MySQL Installation Guide Step1- Install MySQL

MySQL Installation Guide

Step1- Install MySQL

Go to MySQL download page (http://dev.mysql.com/downloads/mysql/). Download the DMG

archive version. Select the correct installer based on your system.

The following description is based on workbench 5.6.17. for Mac .

)

1. Open the downloaded folder:

2. Right click the first item to “open with,” then select “installer.”

3. Click “continue.”

4. Click “continue.”

5. Click “continue.”

6. Click “Agree.”

7. Click “install.”

8. Enter the password and click “install software.”

9. Your installation was successful. Click “close.”

10. Right click “mySQLStartupItem” to “open with,” then select “installer.”

11. Click “continue.”

12. Click “continue.”

13. Pick a location and click “install.”

14. Type in your password and click “install software.”

15. Click “close.”

16. Double click on “MySQL.prefPane.”

17. Click “install” and type in your password.

18. Click “Start MySQL Server” and type in your password.

19. Click “Stop MySQL Server” whenever you want to stop.

You can start and stop the service by opening your System Preferences, where you’ll find them in the

bottom Other row. If the intent was to have it start automatically, sometimes the permissions are

incorrect.

Some helpful guide for setting up configuration:

(http://blog.mclaughlinsoftware.com/2011/02/10/mac-os-x-mysql-install/)

20. Next, download theMySQL workbench (http://dev.mysql.com/downloads/tools/workbench/).

The following description is based on workbench 6.1.4. for Mac .

21. Open the downloaded file and you should see the following:

22.Drag the MySQL Workbench icon to the Application folder.

23. You should see the workbench in the application folder. Double click to open.

STEP 3 - A GUI Tool for MySQL – MySQL Workbench 1. Download the MySQL Workbench from MySQL download page. After the installation, run it and you should see the following:

2. Click on the ‘+’ sign to set up a new connection. Give the connection a name.

3. Click on ‘Test Connection’ and type in your password. Click Ok.

4. If your password is correct, you should get this window. Click Ok.

5. You should see the new connection you created. Double Click on it to start.

STEP 4 - Create Database and Tables

1. Click on “Create a new schema in the connected server” icon on the upper left corner.

2. Create a new schema and name it ‘music.’ Click ‘apply.’

3. Click “apply.”

4. Click ‘Finish.’

5. Schema ‘music’ is created in the left column.

Given below is the schema for the data. There are a total of 5 tables. ● singer (singer_name, sex, age) ● album (album_id, album_title, price) ● song (album_id, song_title, genre) ● sing (singer_name, album_id, song_title) ● release (singer_name, album_id, year)

singer_name: varchar

sex: char

age: integer

album_id: integer

album_title: varchar

price: float

song_title: varchar

genre: varchar

year: integer

Foreign keys: Song album_id references album_id of Album. Sing singer_name references singer_name of Singer. (album_id, song_title) references (album_id, song_title) of Song. Release singer_name references singer_name of Singer. album_id references album_id of Album.

6. Click on the ‘Create new table in the active schema in connected server.’

7. Fill in the table name and columns with attribute names, data types and indicate the primary key(PK) and Not null(NN).

8. Click “apply.”

9. You can right click on the “tables” under the schema to create new tables.

10. Click on the Foreign keys tab and indicate the foreign keys. Click ‘Apply.’

11. Click apply.

STEP 5 – Insert data Given below is the data to be inserted into tables. There are row to be inserted into 5 different tables. INSERT INTO SINGER VALUES ('George Ihler','M',18); INSERT INTO SINGER VALUES ('Fred Smith','M',16); INSERT INTO SINGER VALUES ('Garry Bauer','M',19); INSERT INTO SINGER VALUES ('Fred Dechter','M',24); INSERT INTO SINGER VALUES ('Elena Simpson','F',16); INSERT INTO SINGER VALUES ('Peter Sebastian','M',21); INSERT INTO SINGER VALUES ('Andy Smith','M',23); INSERT INTO SINGER VALUES ('Martha Carey','F',19); INSERT INTO SINGER VALUES ('Martina Packard','F',16); INSERT INTO SINGER VALUES ('Rui Sander','F',17); INSERT INTO SINGER VALUES ('Linda Sander','F',19); INSERT INTO SINGER VALUES ('Rina Bauer','F',23); INSERT INTO SINGER VALUES ('Rina Djokonov','F',24); INSERT INTO SINGER VALUES ('David Liz','M',16); INSERT INTO SINGER VALUES ('Shawn Samson','M',23); INSERT INTO SINGER VALUES ('Thomas Simpson','M',15); INSERT INTO SINGER VALUES ('Shawn Coltz','M',16); INSERT INTO SINGER VALUES ('Elena Carey','F',16); INSERT INTO SINGER VALUES ('Garry Ihler','M',21); INSERT INTO SINGER VALUES ('Andy Dechter','M',23); INSERT INTO ALBUM VALUES (1, 'Spring', 10.00); INSERT INTO ALBUM VALUES (2, 'Summer', 15.00); INSERT INTO ALBUM VALUES (3, 'Fall', 20.00); INSERT INTO ALBUM VALUES (4, 'Winter', 10.00); INSERT INTO ALBUM VALUES (5, 'Cats', 9.00); INSERT INTO ALBUM VALUES (6, 'Love', 25.00); INSERT INTO ALBUM VALUES (7, 'Children', 8.00); INSERT INTO ALBUM VALUES (8, 'God', 30.00); INSERT INTO ALBUM VALUES (9, 'People', 13.00);

INSERT INTO ALBUM VALUES (10, 'Birthday', 21.00); INSERT INTO ALBUM VALUES (11, 'Eternity', 100.00); INSERT INTO ALBUM VALUES (12, 'Mother', 13.00); INSERT INTO ALBUM VALUES (13, 'Father', 20.00); INSERT INTO ALBUM VALUES (14, 'Happiness', 1.00); INSERT INTO ALBUM VALUES (15, 'Joy', 10.00); INSERT INTO SONG VALUES (1, 'Birds and Flowers', 'Classical'); INSERT INTO SONG VALUES (1, 'Rains', 'Classical'); INSERT INTO SONG VALUES (1, 'Trees', 'Classical'); INSERT INTO SONG VALUES (1, 'Breeze', 'Classical'); INSERT INTO SONG VALUES (2, 'Swim Swim Swim', 'Techno'); INSERT INTO SONG VALUES (2, 'Rains', 'Ballad'); INSERT INTO SONG VALUES (2, 'Trees', 'Classical'); INSERT INTO SONG VALUES (2, 'Hot Hot Hot', 'Techno'); INSERT INTO SONG VALUES (3, 'Fruits', 'Pop'); INSERT INTO SONG VALUES (3, 'Mountains', 'Soul'); INSERT INTO SONG VALUES (3, 'Clear Blue Sky', 'Soul'); INSERT INTO SONG VALUES (3, 'Leaves', 'Jazz'); INSERT INTO SONG VALUES (4, 'Snow', 'Electronic'); INSERT INTO SONG VALUES (4, 'Snowman On The Street', 'Pop'); INSERT INTO SONG VALUES (4, 'Skiing Skiing Skiing', 'Techno'); INSERT INTO SONG VALUES (4, 'Icecream', 'Techno'); INSERT INTO SONG VALUES (5, 'Meowing', 'Techno'); INSERT INTO SONG VALUES (5, 'Jump Jump Jump', 'Techno'); INSERT INTO SONG VALUES (5, 'Like A Lion', 'Techno'); INSERT INTO SONG VALUES (5, 'Scary Cat', 'Techno'); INSERT INTO SONG VALUES (6, 'Love Is All Around', 'Ballad'); INSERT INTO SONG VALUES (6, 'One Love', 'Ballad'); INSERT INTO SONG VALUES (6, 'One Sight Love', 'Ballad'); INSERT INTO SONG VALUES (6, 'Addiction', 'Ballad'); INSERT INTO SONG VALUES (7, 'We Are The World', 'Children'); INSERT INTO SONG VALUES (7, 'Going On A Bear Hunt', 'Children'); INSERT INTO SONG VALUES (7, 'Going on A Lion Hunt', 'Children'); INSERT INTO SONG VALUES (7, 'My Life Is All About', 'Children');

INSERT INTO SONG VALUES (8, 'Destiny', 'Gospel'); INSERT INTO SONG VALUES (8, 'Jesus', 'Gospel'); INSERT INTO SONG VALUES (8, 'Believe Or Not', 'Gospel'); INSERT INTO SONG VALUES (8, 'Truth', 'Gospel'); INSERT INTO SONG VALUES (9, 'War', 'Heavy Metal'); INSERT INTO SONG VALUES (9, 'Happiness', 'Jazz'); INSERT INTO SONG VALUES (9, 'The Way Story Goes On', 'Country'); INSERT INTO SONG VALUES (9, 'The Way We Live', 'Country'); INSERT INTO SONG VALUES (10, 'Happy Birthday To You', 'Ballad'); INSERT INTO SONG VALUES (10, '20th Birthday', 'Techno'); INSERT INTO SONG VALUES (10, '50th Birthday', 'Jazz'); INSERT INTO SONG VALUES (10, '80th Birthday', 'Hip-Hop'); INSERT INTO SONG VALUES (11, 'At The End Of The Day', 'Jazz'); INSERT INTO SONG VALUES (11, 'Tombstone', 'Classical'); INSERT INTO SONG VALUES (11, 'I Believe', 'Electronic'); INSERT INTO SONG VALUES (11, 'Love Forever', 'Jazz'); INSERT INTO SONG VALUES (12, 'The First Baby', 'Disco'); INSERT INTO SONG VALUES (12, 'When We Meet Again', 'Techno'); INSERT INTO SONG VALUES (12, 'Mother And Woman', 'R&B'); INSERT INTO SONG VALUES (12, 'I Am Your Mother', 'Rock'); INSERT INTO SONG VALUES (13, 'The First Baby', 'Disco'); INSERT INTO SONG VALUES (13, 'When We Meet Again', 'Techno'); INSERT INTO SONG VALUES (13, 'Father And Man', 'R&B'); INSERT INTO SONG VALUES (13, 'I Am Your Father', 'Rock'); INSERT INTO SONG VALUES (14, 'The First Baby', 'Disco'); INSERT INTO SONG VALUES (14, 'When We Meet Again', 'Techno'); INSERT INTO SONG VALUES (14, 'You Never Know', 'Metal'); INSERT INTO SONG VALUES (14, 'All I Need', 'Ballad'); INSERT INTO SONG VALUES (15, 'The Favorite Food', 'Disco'); INSERT INTO SONG VALUES (15, 'The Favorite Song', 'Techno'); INSERT INTO SONG VALUES (15, 'The Favorite Movie', 'R&B'); INSERT INTO SONG VALUES (15, 'All I Need', 'Ballad'); INSERT INTO SONG VALUES (15, 'Love Actually', 'Ballad'); INSERT INTO SING VALUES ('Garry Bauer', 1, 'Birds and Flowers');

INSERT INTO SING VALUES ('Garry Bauer', 1, 'Rains'); INSERT INTO SING VALUES ('Garry Bauer', 1, 'Trees'); INSERT INTO SING VALUES ('Garry Bauer', 1, 'Breeze'); INSERT INTO SING VALUES ('Fred Dechter', 2, 'Swim Swim Swim'); INSERT INTO SING VALUES ('Fred Dechter', 2, 'Rains'); INSERT INTO SING VALUES ('Fred Dechter', 2, 'Trees'); INSERT INTO SING VALUES ('Fred Dechter', 2, 'Hot Hot Hot'); INSERT INTO SING VALUES ('Elena Simpson', 3, 'Fruits'); INSERT INTO SING VALUES ('Elena Simpson', 3, 'Mountains'); INSERT INTO SING VALUES ('Elena Simpson', 3, 'Clear Blue Sky'); INSERT INTO SING VALUES ('Elena Simpson', 3, 'Leaves'); INSERT INTO SING VALUES ('Peter Sebastian', 4, 'Snow'); INSERT INTO SING VALUES ('Peter Sebastian', 4, 'Snowman On The Street'); INSERT INTO SING VALUES ('Peter Sebastian', 4, 'Skiing Skiing Skiing'); INSERT INTO SING VALUES ('Peter Sebastian', 4, 'Icecream'); INSERT INTO SING VALUES ('Andy Smith', 4, 'Snow'); INSERT INTO SING VALUES ('Andy Smith', 4, 'Snowman On The Street'); INSERT INTO SING VALUES ('Andy Smith', 4, 'Skiing Skiing Skiing'); INSERT INTO SING VALUES ('Andy Smith', 4, 'Icecream'); INSERT INTO SING VALUES ('Martha Carey', 5, 'Meowing'); INSERT INTO SING VALUES ('Martha Carey', 5, 'Jump Jump Jump'); INSERT INTO SING VALUES ('Martha Carey', 5, 'Like A Lion'); INSERT INTO SING VALUES ('Martha Carey', 5, 'Scary Cat'); INSERT INTO SING VALUES ('Martina Packard', 6, 'Love Is All Around'); INSERT INTO SING VALUES ('Martina Packard', 6, 'One Love'); INSERT INTO SING VALUES ('Martina Packard', 6, 'One Sight Love'); INSERT INTO SING VALUES ('Martina Packard', 6, 'Addiction'); INSERT INTO SING VALUES ('Rui Sander', 7, 'We Are The World'); INSERT INTO SING VALUES ('Rui Sander', 7, 'Going On A Bear Hunt'); INSERT INTO SING VALUES ('Rui Sander', 7, 'Going on A Lion Hunt'); INSERT INTO SING VALUES ('Rui Sander', 7, 'My Life Is All About'); INSERT INTO SING VALUES ('Rui Sander', 8, 'Destiny'); INSERT INTO SING VALUES ('Rui Sander', 8, 'Jesus'); INSERT INTO SING VALUES ('Linda Sander', 8, 'Believe Or Not'); INSERT INTO SING VALUES ('Linda Sander', 8, 'Truth');

INSERT INTO SING VALUES ('Rina Bauer', 9, 'War'); INSERT INTO SING VALUES ('Rina Bauer', 9, 'Happiness'); INSERT INTO SING VALUES ('Rina Bauer', 9, 'The Way Story Goes On'); INSERT INTO SING VALUES ('Rina Bauer', 9, 'The Way We Live'); INSERT INTO SING VALUES ('David Liz', 10, 'Happy Birthday To You'); INSERT INTO SING VALUES ('Shawn Samson', 10, '20th Birthday'); INSERT INTO SING VALUES ('Thomas Simpson', 10, '50th Birthday'); INSERT INTO SING VALUES ('Shawn Coltz', 10, '80th Birthday'); INSERT INTO SING VALUES ('Elena Carey', 11, 'At The End Of The Day'); INSERT INTO SING VALUES ('Elena Carey', 11, 'Tombstone'); INSERT INTO SING VALUES ('Elena Carey', 11, 'I Believe'); INSERT INTO SING VALUES ('Elena Carey', 11, 'Love Forever'); INSERT INTO SING VALUES ('Andy Dechter', 12, 'The First Baby'); INSERT INTO SING VALUES ('Andy Dechter', 12, 'When We Meet Again'); INSERT INTO SING VALUES ('Andy Dechter', 12, 'Mother And Woman'); INSERT INTO SING VALUES ('Andy Dechter', 12, 'I Am Your Mother'); INSERT INTO SING VALUES ('Andy Dechter', 13, 'The First Baby'); INSERT INTO SING VALUES ('Elena Simpson', 13, 'When We Meet Again'); INSERT INTO SING VALUES ('Peter Sebastian', 13, 'Father And Man'); INSERT INTO SING VALUES ('Andy Smith', 13, 'I Am Your Father'); INSERT INTO SING VALUES ('Martha Carey', 14, 'The First Baby'); INSERT INTO SING VALUES ('Martha Carey', 14, 'When We Meet Again'); INSERT INTO SING VALUES ('Martha Carey', 14, 'You Never Know'); INSERT INTO SING VALUES ('Martha Carey', 14, 'All I Need'); INSERT INTO SING VALUES ('Rui Sander', 15, 'The Favorite Food'); INSERT INTO SING VALUES ('Rui Sander', 15, 'The Favorite Song'); INSERT INTO SING VALUES ('Rui Sander', 15, 'The Favorite Movie'); INSERT INTO SING VALUES ('Rui Sander', 15, 'All I Need'); INSERT INTO SING VALUES ('Rui Sander', 15, 'Love Actually'); INSERT INTO RELEASE VALUES ('Garry Bauer', 1, 1980); INSERT INTO RELEASE VALUES ('Fred Dechter', 2, 1981); INSERT INTO RELEASE VALUES ('Elena Simpson', 3, 1982); INSERT INTO RELEASE VALUES ('Peter Sebastian', 4, 1983); INSERT INTO RELEASE VALUES ('Martha Carey', 5, 1999);

INSERT INTO RELEASE VALUES ('Martina Packard', 6, 1998); INSERT INTO RELEASE VALUES ('Rui Sander', 7, 2010); INSERT INTO RELEASE VALUES ('Linda Sander', 8, 2011); INSERT INTO RELEASE VALUES ('Rina Bauer', 9, 1976); INSERT INTO RELEASE VALUES ('David Liz', 10, 2001); INSERT INTO RELEASE VALUES ('Shawn Samson', 10, 2001); INSERT INTO RELEASE VALUES ('Thomas Simpson', 10, 2001); INSERT INTO RELEASE VALUES ('Shawn Coltz', 10, 2001); INSERT INTO RELEASE VALUES ('Elena Carey', 11, 1999); INSERT INTO RELEASE VALUES ('Andy Dechter', 12, 2011); INSERT INTO RELEASE VALUES ('Andy Dechter', 13, 2012); INSERT INTO RELEASE VALUES ('Martha Carey', 14, 2009); INSERT INTO RELEASE VALUES ('Rui Sander', 15, 2007);

1. In order to insert data, right click on a table, select ‘send to SQL editor’ and click on ‘insert statement.’

2. Type in your insert statements.

3. Click on the thunder shaped icon to execute the insert statements.

STEP 6 - Form SQL Queries 1. In order to form queries, type in the query in the ‘Query’ tab and click on the thunder shaped

icon. You will see your results in the box below.

2. You can export the result into a csv file.