Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
46 views

MySQL Server Installation

This document provides instructions for installing MySQL server on Ubuntu, including downloading a VMware disk, extracting and booting the virtual machine, updating packages, installing MySQL, checking the MySQL status, logging into MySQL as the root user, creating a new database and user, granting privileges to the user, and inserting and querying data from a sample TODO table.

Uploaded by

Mildd Amrsk
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

MySQL Server Installation

This document provides instructions for installing MySQL server on Ubuntu, including downloading a VMware disk, extracting and booting the virtual machine, updating packages, installing MySQL, checking the MySQL status, logging into MySQL as the root user, creating a new database and user, granting privileges to the user, and inserting and querying data from a sample TODO table.

Uploaded by

Mildd Amrsk
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lab 2: MySQL Server Installation on Ubuntu

1. Download VMWare Disk and Save it in Downloads folder


https://web.sit.kmutt.ac.th/sanit/int203/Ubuntu_64-bit_Server_18.zip
2. Extract the zip file and open the folder and look for “Ubuntu 64-bit Server 18.04.3.vmx” and
right-click the file > Open with VMWare Workstation > Power on this virtual machine
3. Click “I Copied it”

4. After booting successfully, Enter login: dba and password: dba

5. It will show the prompt as follows:

6. Installing MySQL Server 5.7 on Ubuntu as follows:


https://linuxize.com/post/how-to-install-mysql-on-ubuntu-18-04/
7. Update the apt package and Enter password as dba
$ sudo apt update
[sudo] password for dba: dba
8. Install MySQL package and type ‘Y’ to continue the installation, type:
$ sudo apt install mysql-server

9. After the installation is completed, the MySQL will start automatically. You can check the status
of MySQL server by typing this command:
$sudo systemctl status mysql

10. To log in the MySQL server as the root user type:


$sudo mysql
11. To show databases by typing:
mysql> show databases ;

12. To show the list of users in the MySQL system, type:


mysql> use mysql
mysql> select user, host, authentication_string, plugin from user ;

13. To create a new database called lab2, type:


mysql> create database lab2 ;

14. To switch to the database lab2, type:


mysql> use lab2 ;

15. To show the list of tables, type:

16. To create a new user named ‘user1’@’localhost’ with the password ‘dbms’, type:
17. To verify the user was created, type:

18. To grant all privileges to allow the user ‘user1’ to manage the database ‘lab2’, type:

19. To verify the privileges granted to the user ‘user1’@’localhost’, type:

20. Exit the mysql program and log in as ‘user1’@’localhost’, type:

21. Type ‘dbms’ for the password and switch to use the database ‘lab2’, type:

22. Type the command to show all tables in the database ‘lab2’
…………………………………………………………..
23. To create a table TODOS with the following structure:
24. Type command to shows all tables in the database lab2:
…………………………………………………………..
25. To show the structure of the table todos, type:

Data in the table todos are shown as follows:

No To-do Due Date Completed


1 INT203 First Class 2019-08-19 Y
2 INT203 Second Class 2019-08-26 N
3 Exchange Maximization Expo 2019-08-26 N

26. To insert the row no 1, type:

By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute
a statement that modifies (insert/update/delete) a table. Thus, you do not need to use the commit
command to save the modified data.
27. Write a SQL statement to show all rows in the table todos.
………………………………………………………………..
28. Write SQL statement(s) to insert the row no 2 and 3.
………………………………………………………………..
………………………………………………………………..
29. Write a SQL statement to show all rows in the table todos.
………………………………………………………………..
30. Query the todos data and show only completed data (completed with ‘Y’)

By default, MySQL queries are not case-sensitive. Try to change the WHERE clause from
complete='Y' to completed='y'. However, Oracle queries are case-sensitive. You cannot find any
row when you use the expression “completed='y'” in the WHERE clause.
31. Write a SQL statement to modify all data by setting the column completed to ‘Y’ in the table
todos.
………………………………………………………………..
32. Write a SQL statement to show all modified rows in the table todos.
………………………………………………………………..
33. To exit the mysql program , type:

34. To shutdown the Ubuntu, type:


$sudo shutdown -h now

You might also like