You are on page 1of 11

MÔN HỌC: CƠ SỞ DỮ LIỆU Họ và tên: Mai Ngọc Duy

MÃ HỌC PHẦN: INT2211 44 Lớp: K66 CACLC2


MSV: 21020512
Bài tập về nhà Tuần 1

*****

Bài 1: How to change the default port of MySQL server to 3307 and connect to
MySQL server at this port?
+ Bước 1: Mở Notepad -> Run as adminstrator. Sau đó ấn vào File -> C:\Program Data -> MySQL -> MSQL
Server 8.0 -> Mở chế độ nhìn All Files -> my.ini
+ Bước 2: Sửa port chỗ dưới socket=MYSQL và The TCP/IP Port the MySQL Server will listen on thành 3307

+ Bước 3: Mở Services -> Dừng hoạt động MySQL80

+ Bước 4: Mở Windows Security -> Firewall & Network Protection -> Advanced settings. Trong Windows
Defender Firewall with Advanced Security, mở Inbound Rules -> New Rule. Sau đó chọn Port -> Next -> Điền
3307 vào Specific Local Port -> Next -> Next -> Tắt Public -> Chọn tên -> Finish. Lúc này sẽ xuất hiện Port
3307
+ Bước 5: Bật lại MYSQL80 trong Services
+ Bước 6: Mở cmd, đăng nhập và kiểm tra port bằng lệnh select @@port; . Ta sẽ thấy port hiện tại là 3307

Bài 2: . How to move the data directory of MySQL to another directory and
reconfigure the configuration file to redirect to new data directory
+ Bước 1: Tắt MYSQL80 như bài 1 ở Service
+ Bước 2: Vào C:\ -> ProgramData -> MySQL -> MySQL Server 8.0. Copy file ‘Data’ và copy vào 1 folder
khác (VD: Folder ‘MySQL Data’ ở ổ E)

+ Bước 4: Mở Notepad -> Run as adminstrator. Sau đó ấn vào File -> C:\Program Data -> MySQL -> MSQL
Server 8.0 -> Mở chế độ nhìn All Files -> my.ini
+ Bước 5: Sửa path như hình dưới (thêm dấu # và thêm địa chỉ file mới vừa tạo)

+ Bước 6: Bật lại MYSQL80 trong Services


Bài 3: Write the correct SQL statement to list all the exsisting databases in MySQL
Để hiện toàn bộ các database, ta sử dụng câu lệnh show databases;

Bài 4: Write the correct SQL statement to create a new database called
“my_database”.
Để thêm 1 database mới vào csdl, ta dùng lệnh create database database_name;
Bài 5: Write the correct SQL statement to delete the database “my_database”
Để xóa 1 database mới vào csdl, ta dùng lệnh drop database database_name;

You might also like