Trong hệ sinh thái dữ liệu lớn hiện đại, MySQL là một trong những công nghệ nổi tiếng nhất. Nó cũng được coi là một cơ sở dữ liệu phổ biến và hiệu quả trên nhiều ngành công nghiệp. Để làm chủ hệ quản trị cơ sở dữ liệu này chỉ cần có hiểu biết cơ bản. Ngay cả khi bạn không quen với các hệ thống quan hệ, bạn có thể tạo các hệ thống lưu trữ an toàn, nhanh chóng và mạnh mẽ với MySQL
Bài viết này sẽ thảo luận về quy trình cài đặt MySQL trên Ubuntu 22. 04. Vì vậy, hãy bắt đầu
Cách cài đặt MySQL trên Ubuntu 22. 04
Để cài đặt MySQL trên Ubuntu 22. 04, trước tiên, thực hiện các kho lưu trữ hệ thống và sau đó thực hiện lệnh “sudo apt-get install mysql-server”. Sau đó, định cấu hình nó trên hệ thống của bạn bằng lệnh “sudo mysql_secure_installation”. Sử dụng hướng dẫn cấu hình, bạn có thể đặt cấp chính sách xác thực mật khẩu, xóa cơ sở dữ liệu thử nghiệm và quyền truy cập của nó, đồng thời tải lại các đặc quyền. Bài viết này đã thảo luận về phương pháp cài đặt MySQL trên Ubuntu 22. 04
Người dùng Ubuntu có thể lựa chọn giữa hai Hệ thống quản lý cơ sở dữ liệu quan hệ [RDBMS] đáng tin cậy, MySQL và MariaDB. MySQL có một lợi thế lâu dài về mức độ phổ biến, nhưng MariaDB ngày càng được quan tâm nhiều hơn do các lợi thế về hiệu suất và các tính năng bổ sung của nó. Hướng dẫn này so sánh hai hệ thống cơ sở dữ liệu và cung cấp hướng dẫn về cách cài đặt và sử dụng MySQL trên Ubuntu 20. 04
MySQL là gì?
MySQL RDBMS là một trong những ứng dụng nguồn mở phổ biến nhất. Nó là một phần của LAMP Stack, nền tảng của nhiều hệ thống Ubuntu. Ngăn xếp này bao gồm Linux, máy chủ web Apache, MySQL RDBMS và ngôn ngữ lập trình PHP. Các ứng dụng này hoạt động cùng nhau để hỗ trợ các ứng dụng web, phát triển phần mềm và các hoạt động chuyên biệt như khoa học dữ liệu. Công dụng chính của MySQL là trong các cấu hình máy chủ đơn vừa và nhỏ
Truy vấn MySQL được viết bằng Ngôn ngữ truy vấn có cấu trúc [SQL]. Là một cơ sở dữ liệu quan hệ, nó lưu trữ và tổ chức dữ liệu trong các bảng. Bảng cấu trúc dữ liệu thực tế bên trong bảng dưới dạng một chuỗi các hàng, với mỗi hàng bao gồm một hoặc nhiều cột. Mỗi hàng đại diện cho một mục nhập khác nhau trong bảng, trong khi mỗi cột chứa một trường dữ liệu trong mục nhập đó. Các trường dữ liệu trong các bảng này có thể liên quan đến nhau và các mối quan hệ này giúp cấu trúc và tổ chức cơ sở dữ liệu. Các câu lệnh SQL chuyên dụng cho phép khách hàng thêm, xóa, sửa đổi và truy xuất dữ liệu
MySQL được biết đến với tính ổn định và đáng tin cậy, đồng thời được coi là đơn giản và dễ sử dụng. Nó có sẵn dưới dạng phần mềm mã nguồn mở miễn phí theo Giấy phép Công cộng GNU. MySQL có sẵn cho tất cả các bản phân phối Linux cũng như các hệ điều hành khác. Nó hiện thuộc sở hữu của Tập đoàn Oracle. Oracle cũng cung cấp MySQL Enterprise Edition thương mại như một sản phẩm cao cấp hơn
MySQL so với. MariaDB
Hai lựa chọn thay thế cơ sở dữ liệu nguồn mở chính, MySQL và MariaDB, rất giống nhau. Cả hai đều là sản phẩm RDBMS và cả hai đều sử dụng SQL. Cả hai hệ thống cơ sở dữ liệu đều có phiên bản miễn phí, chúng trông và hoạt động theo cùng một cách. Bởi vì MariaDB ban đầu được phân nhánh từ MySQL, điều này không có gì đáng ngạc nhiên. MariaDB kể từ đó đã trải qua quá trình phát triển hơn nữa và có nhiều cải tiến mới về bảo mật và hiệu suất. Tuy nhiên, với MySQL, nhiều tính năng nâng cao chỉ có trong Phiên bản doanh nghiệp. Dưới đây là tổng hợp những điểm giống và khác nhau giữa hai sản phẩm
- MariaDB hỗ trợ nhiều kết nối hơn MySQL
- Cả hai cơ sở dữ liệu đều có thể hoạt động với nhiều hệ thống lưu trữ, mặc dù MariaDB cung cấp nhiều tùy chọn hơn
- MariaDB có thể sao chép dữ liệu nhanh hơn MySQL và có hiệu suất tổng thể tốt hơn. MySQL xử lý các giao dịch lớn hiệu quả hơn, nhưng MariaDB hoạt động tốt hơn trong các tình huống mở rộng
- MySQL hỗ trợ một số tính năng mà MariaDB không có, chẳng hạn như các cột động. Mỗi cơ sở dữ liệu có một vài tính năng và cải tiến nâng cao mà cơ sở dữ liệu kia không có
- MySQL cũ hơn, được thiết lập tốt hơn, phổ biến hơn và có nhiều hỗ trợ cộng đồng hơn. MySQL cung cấp các gói hỗ trợ trả phí toàn diện hơn
- MariaDB và MySQL hoàn toàn tương thích
- Cả hai sản phẩm đều là nguồn mở, nhưng mô hình cấp phép MySQL hạn chế hơn
Tóm lại, cả hai hệ thống đều quá đủ cho hầu hết người dùng. MariaDB có hiệu suất tốt hơn, trong khi MySQL được thiết lập tốt hơn và được hỗ trợ tốt hơn
Trước khi bắt đầu
Ghi chúCác bước trong hướng dẫn này được viết cho người dùng không root. Các lệnh yêu cầu đặc quyền nâng cao có tiền tố là
8. Nếu bạn không quen với lệnhVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
8, hãy xem hướng dẫn Người dùng và Nhóm LinuxVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Cách cài đặt máy chủ MySQL
MySQL có sẵn như là một phần của các gói Ubuntu mặc định, vì vậy không cần thiết phải chỉnh sửa danh sách nguồn. Nó có thể được cài đặt dễ dàng bằng cách sử dụng
Please set the password for root here.
New password:
Re-enter new password:
0, nhưng điều quan trọng là phải bảo mật ứng dụng và chỉnh sửa tường lửa sau đó. Các hướng dẫn này hướng đến người dùng Ubuntu, nhưng thường áp dụng cho những người muốn cài đặt MySQL trên một bản phân phối Linux khácTải xuống MySQL
Để cài đặt máy chủ MySQL trên Ubuntu, hãy làm theo các bước dưới đây
Cài đặt ứng dụng máy chủ MySQL
sudo apt install mysql-server
Xác nhận máy chủ MySQL đang chạy bằng lệnh
1. Nó sẽ hiển thị trạng thái củaPlease set the password for root here. New password: Re-enter new password:
2Please set the password for root here. New password: Re-enter new password:
sudo systemctl status mysql
mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
Cấu hình máy chủ MySQL trên Linux
Tiện ích
Please set the password for root here.
New password:
Re-enter new password:
3 là cách dễ nhất để cấu hình ứng dụng. Để sử dụng tập lệnh thiết lập, hãy làm theo các bước sauKhởi chạy tiện ích
3 để đặt mật khẩu gốc và định cấu hình các tùy chọn mặc định khácPlease set the password for root here. New password: Re-enter new password:
0VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Ứng dụng hỏi có bật thành phần
5 không. Nếu bạn trả lờiPlease set the password for root here. New password: Re-enter new password:
6, nó sẽ hỏi bạn có đặt độ mạnh mật khẩu thànhPlease set the password for root here. New password: Re-enter new password:
7,Please set the password for root here. New password: Re-enter new password:
8 hayPlease set the password for root here. New password: Re-enter new password:
9 hay khôngPlease set the password for root here. New password: Re-enter new password:
VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Tại dấu nhắc tiếp theo, tiện ích yêu cầu nhập mật khẩu cho tài khoản root. Đặt mật khẩu rồi nhập lại
Please set the password for root here. New password: Re-enter new password:
Các câu hỏi sau hỏi liệu có xóa người dùng ẩn danh hay không, cho phép tài khoản
80 kết nối từ xa và xóa cơ sở dữ liệuVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
81. NhậpVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
6 hoặcPlease set the password for root here. New password: Re-enter new password:
83 tại mỗi dấu nhắc tùy theo sở thích của bạn. Cơ sở dữ liệuVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
81 rất hữu ích trong quá trình xác thực ban đầu, nhưng vì lý do bảo mật, tốt nhất là không cho phép tài khoảnVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
80 đăng nhập từ xaVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
8VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Khi được nhắc, hãy tải lại các bảng
86 để cập nhật cơ sở dữ liệuVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
6Please set the password for root here. New password: Re-enter new password:
7____28Please set the password for root here. New password: Re-enter new password:
[Tùy chọn] Để truy cập MySQL từ xa, hãy đảm bảo rằng lưu lượng truy cập MySQL được cho phép thông qua tường lửa
87. Thêm quy tắc sau để mở cổngVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
88 trên tường lửa. Không nên thêm quy tắc này nếu không cần truy cập từ xaVALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
0sudo systemctl status mysql
1sudo systemctl status mysql
Đăng nhập vào MySQL với tư cách Người dùng gốc
Mặc dù người dùng
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
80 có toàn quyền truy cập vào cơ sở dữ liệu MySQL, nhưng việc sử dụng nó nên được dành riêng cho mục đích quản trị. Điều này làm giảm khả năng vô tình ghi đè lên các phần quan trọng của cơ sở dữ liệu. Ngay cả trong thiết lập một người dùng, nên tạo một tài khoản người dùng riêng cho hầu hết các hoạt động của MySQLĐể truy cập máy chủ MySQL với tư cách là người dùng
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
80 và tạo tài khoản người dùng mới, hãy làm theo các bước sauSử dụng lệnh
61 để truy cập cơ sở dữ liệu. MySQL xác thực người dùng root dựa trên thông tin đăng nhập gốc của họ khi đăng nhập cục bộ, do đó không cần mật khẩu. Ngoài ra, truy cập tài khoản gốc bằng cách sử dụngPlease set the password for root here. New password: Re-enter new password:
62, cùng với mật khẩuPlease set the password for root here. New password: Re-enter new password:
80VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
2sudo systemctl status mysql
MySQL hiển thị số phát hành và một số thông tin về cài đặt, sau đó hiển thị dấu nhắc MySQL
3sudo systemctl status mysql
Để xác nhận MySQL đang hoạt động chính xác, hãy sử dụng lệnh
64 để hiển thị tất cả các cơ sở dữ liệuPlease set the password for root here. New password: Re-enter new password:
4sudo systemctl status mysql
5sudo systemctl status mysql
Tạo người dùng mới bằng lệnh
65. Nhập tên người dùng ở định dạngPlease set the password for root here. New password: Re-enter new password:
66, trong đóPlease set the password for root here. New password: Re-enter new password:
67 là địa chỉ IP của người dùng. Nếu người dùng đang truy cập MySQL từ Linode cục bộ, hãy thay thếPlease set the password for root here. New password: Re-enter new password:
68 thay cho Địa chỉ IP. Trong lệnh bên dưới, thay thếPlease set the password for root here. New password: Re-enter new password:
69 vàPlease set the password for root here. New password: Re-enter new password:
70 bằng tên người dùng và mật khẩu thực tếPlease set the password for root here. New password: Re-enter new password:
Ghi chú
MySQL cung cấp một số cơ chế xác thực khác nhau. Phương pháp
71 được khuyến nghị cho những người dùng muốn đăng nhập bằng mật khẩu và được sử dụng tại đây. Tuy nhiên, một số ứng dụng cũ hơn có thể không xác thực đúng theo cách này. Trong trường hợp đó, nên sử dụngPlease set the password for root here. New password: Re-enter new password:
72 để thay thế. Bản sao nguồn-bản sao của MySQL có thể yêu cầu phương thứcPlease set the password for root here. New password: Re-enter new password:
73Please set the password for root here. New password: Re-enter new password:
6sudo systemctl status mysql
Cấp quyền truy cập cho người dùng mới bằng lệnh
74, sử dụng định dạngPlease set the password for root here. New password: Re-enter new password:
75. Một số đặc quyền phổ biến hơn bao gồmPlease set the password for root here. New password: Re-enter new password:
76,Please set the password for root here. New password: Re-enter new password:
77,Please set the password for root here. New password: Re-enter new password:
78,Please set the password for root here. New password: Re-enter new password:
79,Please set the password for root here. New password: Re-enter new password:
80,Please set the password for root here. New password: Re-enter new password:
81 vàPlease set the password for root here. New password: Re-enter new password:
82. Để áp dụng các đặc quyền này cho tất cả các cơ sở dữ liệu, hãy sử dụng biến ký tự đại diệnPlease set the password for root here. New password: Re-enter new password:
83. Lệnh sau cấp các đặc quyền phi quản trị chung trên tất cả các cơ sở dữ liệu choPlease set the password for root here. New password: Re-enter new password:
69Please set the password for root here. New password: Re-enter new password:
7sudo systemctl status mysql
Để thoát khỏi dấu nhắc MySQL, hãy nhập
85Please set the password for root here. New password: Re-enter new password:
8sudo systemctl status mysql
Cách sử dụng MySQL
MySQL sử dụng cú pháp SQL tiêu chuẩn cho tất cả các lệnh của nó. Các bước trong phần này trình bày cách thực hiện các tác vụ cơ bản trong MySQL, chẳng hạn như tạo cơ sở dữ liệu, bảng và thêm dữ liệu. Để biết thông tin đầy đủ về cách sử dụng MySQL, hãy xem MySQL Reference Manual. Để có phần giới thiệu ngắn gọn nhưng kỹ lưỡng, hãy thử hướng dẫn về MySQL
Tạo cơ sở dữ liệu
Để tạo cơ sở dữ liệu, hãy đăng nhập vào MySQL bằng tài khoản có đặc quyền
76. Thay thếPlease set the password for root here. New password: Re-enter new password:
87 bằng tên người dùng bạn đã tạoPlease set the password for root here. New password: Re-enter new password:
9sudo systemctl status mysql
Tạo cơ sở dữ liệu mới bằng lệnh
88. Thay thếPlease set the password for root here. New password: Re-enter new password:
89 bằng tên mong muốn cho cơ sở dữ liệu của bạnPlease set the password for root here. New password: Re-enter new password:
0mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
1mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
Để xác nhận cơ sở dữ liệu mới đã được tạo chính xác, hãy sử dụng
64Please set the password for root here. New password: Re-enter new password:
4sudo systemctl status mysql
3mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
Cho biết cơ sở dữ liệu mà bạn muốn làm việc bằng cách sử dụng lệnh
01. Thay thếsudo systemctl status mysql
89 bằng tên cơ sở dữ liệu mà bạn vừa tạoPlease set the password for root here. New password: Re-enter new password:
4mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
5mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
Ghi chú
Bạn cũng có thể sử dụng lệnh
01 khi có nhiều hơn một cơ sở dữ liệu và bạn muốn chuyển đổi giữa chúngsudo systemctl status mysql
Để tìm ra tên của cơ sở dữ liệu hiện tại, hãy sử dụng lệnh
04. Đầu ra hiển thị tên cơ sở dữ liệusudo systemctl status mysql
6mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
7mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
Tạo một bảng
Tại thời điểm này, cơ sở dữ liệu,
Please set the password for root here.
New password:
Re-enter new password:
89 không có bất kỳ bảng nào, vì vậy không thể lưu trữ bất kỳ dữ liệu nào trong đó. Để xác định một bảng, hãy sử dụng lệnh sudo systemctl status mysql
06. Cùng với tên của bảng, lệnh này yêu cầu tên và kiểu dữ liệu của từng trường. Kiểu dữ liệu đặc trưng cho dữ liệu được lưu trữ trong trường. Ví dụ: kiểu dữ liệu có thể là một chuỗi có độ dài thay đổi, được gọi là sudo systemctl status mysql
07. Để biết danh sách đầy đủ các loại dữ liệu, hãy tham khảo tài liệu về MySQL. Một số kiểu dữ liệu phổ biến hơn như sau- INT. Điều này có thể chứa một giá trị giữa
08 vàsudo systemctl status mysql
09. Nếu được chỉ định làsudo systemctl status mysql
10, nó có thể lưu trữ các giá trị giữasudo systemctl status mysql
11 vàsudo systemctl status mysql
12sudo systemctl status mysql
- NHỎ. Giữ một giá trị số nguyên thậm chí còn nhỏ hơn giữa
13 vàsudo systemctl status mysql
14sudo systemctl status mysql
- TRÔI NỔI. Loại này có thể lưu trữ một số dấu phẩy động
- NGÀY. Lưu trữ một ngày ở định dạng
15sudo systemctl status mysql
- NGÀY GIỜ. Lưu trữ kết hợp ngày và giờ ở định dạng
16. Đồng thời có thể được lưu trữ mà không có dấu gạch ngang và dấu hai chấm ở định dạngsudo systemctl status mysql
17sudo systemctl status mysql
- VARCHAR[N]. Đây là một chuỗi có độ dài thay đổi từ
18 đếnsudo systemctl status mysql
19 ký tự, với độ dài tối đa làsudo systemctl status mysql
20 ký tựsudo systemctl status mysql
- CHỮ. Loại dữ liệu này chứa tối đa
21 ký tự. Nó có thể chứa văn bản, hình ảnh hoặc dữ liệu nhị phânsudo systemctl status mysql
- CHAR[N]. Loại này đại diện cho trường văn bản có độ dài cố định có độ dài
19. Ví dụ: để giữ mã trạng thái gồm hai ký tự, hãy sử dụng loại dữ liệu làsudo systemctl status mysql
23sudo systemctl status mysql
Trước khi tạo bất kỳ bảng nào, điều quan trọng là phải quyết định lược đồ cho cơ sở dữ liệu. Lược đồ mô tả mỗi bảng đại diện cho cái gì, dữ liệu nào được lưu trữ trong mỗi bảng và các bảng liên quan với nhau như thế nào. Để tạo một bảng, hãy làm theo các bước sau
Trong khi đăng nhập vào MySQL, hãy chuyển sang cơ sở dữ liệu nơi bạn muốn thêm bảng
8mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
Sử dụng lệnh
06 để tạo bảng mới. Sử dụng định dạngsudo systemctl status mysql
25sudo systemctl status mysql
9mysql.service - MySQL Community Server Loaded: loaded [/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active [running] since Thu 2021-09-09 12:24:29 UTC; 1h 44min ago
00VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Để xác nhận bảng hiện đã tồn tại, hãy sử dụng lệnh
26sudo systemctl status mysql
01VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
02VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Để xem lại cấu trúc bảng và xác minh danh sách các trường, hãy sử dụng lệnh
27sudo systemctl status mysql
03VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
04VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Nếu một bảng không còn cần thiết, hãy xóa nó bằng lệnh
28sudo systemctl status mysql
thận trọng
Khi một bảng bị hủy, tất cả dữ liệu bên trong bảng sẽ bị mất và không thể khôi phục được
05VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Thêm và truy xuất dữ liệu
Cách chính để chèn một hàng dữ liệu mới vào bảng là sử dụng lệnh
Please set the password for root here.
New password:
Re-enter new password:
79Để thêm một hàng, hãy sử dụng lệnh
79. Chỉ định tên bảng, từ khóaPlease set the password for root here. New password: Re-enter new password:
31 và danh sách các giá trị được phân tách bằng dấu phẩy trong dấu ngoặc vuông ở định dạngsudo systemctl status mysql
32. Các giá trị cột phải có cùng trình tự như định nghĩa bảng, với các giá trị chuỗi và ngày trong dấu ngoặc kép. Ví dụ: để thêm dữ liệu vàosudo systemctl status mysql
33, hãy chỉ định các giá trị chosudo systemctl status mysql
34,sudo systemctl status mysql
35,sudo systemctl status mysql
36 vàsudo systemctl status mysql
37 theo thứ tự đósudo systemctl status mysql
06VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
07VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Để truy xuất dữ liệu, hãy sử dụng lệnh
82, cùng với một số ràng buộc cho MySQL biết hàng nào sẽ trả về. Toàn bộ nội dung của bảng có thể được trả về hoặc chỉ một tập hợp con. Để chọn tất cả các hàng trong một bảng, hãy sử dụng lệnhPlease set the password for root here. New password: Re-enter new password:
39, nhưng không thêm bất kỳ từ hạn định nàosudo systemctl status mysql
08VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
09VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Cũng có thể chỉ chọn các hàng phù hợp với tiêu chí cụ thể, chẳng hạn như cột được đặt thành một giá trị nhất định. Sử dụng từ khóa
40 làm hạn định, theo sau là tiêu chí đối sánh làm ràng buộc. Trong ví dụ này, chỉ những hàng trong đósudo systemctl status mysql
35 được đặt thànhsudo systemctl status mysql
42 mới được hiển thịsudo systemctl status mysql
0VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
1VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Đối với các bảng có nhiều cột, việc giới hạn thông tin được hiển thị thường dễ dàng hơn. Để chỉ chọn một số cột nhất định cho mỗi hàng, hãy chỉ định tên cột thay vì ký hiệu
43sudo systemctl status mysql
2____03VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Để sửa đổi một hàng trong bảng, hãy sử dụng lệnh
80. Từ khóaPlease set the password for root here. New password: Re-enter new password:
45 cho biết cột cần cập nhật và giá trị mới. Nếu cần, từ khóasudo systemctl status mysql
40 cung cấp phương pháp hạn chế thao tác chỉ áp dụng cho một số hàng nhất định. Trong ví dụ sau, giá trị củasudo systemctl status mysql
37 chỉ được thay đổi thànhsudo systemctl status mysql
48 nếusudo systemctl status mysql
35 bằng vớisudo systemctl status mysql
42sudo systemctl status mysql
4VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
5VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Câu lệnh
39 có thể được sử dụng để xác nhận cập nhậtsudo systemctl status mysql
08VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
7VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Sự kết luận. MySQL trên Ubuntu 20. 04
MySQL là một lựa chọn tốt cho các ứng dụng web vừa và nhỏ. Nó sử dụng ngôn ngữ lập trình SQL tiêu chuẩn công nghiệp, khá dễ sử dụng. MySQL rất ổn định và mạnh mẽ và có nhiều tài nguyên cùng với sự hỗ trợ tốt. Giải pháp thay thế chính cho MySQL là MariaDB. Nó có hiệu suất tốt hơn và các tính năng mới hơn, nhưng không được thiết lập tốt
Bạn có thể dễ dàng tải xuống và cài đặt máy chủ MySQL trên Ubuntu bằng các gói
Please set the password for root here.
New password:
Re-enter new password:
0 và tiện ích Please set the password for root here.
New password:
Re-enter new password:
3. Ngay cả khi bạn là người duy nhất đang sử dụng MySQL, tốt nhất bạn nên tạo một người dùng MySQL mới với các đặc quyền hạn chế hơnĐể sử dụng MySQL, trước tiên hãy xác định lược đồ cơ sở dữ liệu và xác định nội dung bảng. Tiếp theo, tạo cơ sở dữ liệu và các bảng dữ liệu. Có thể thêm dữ liệu bằng lệnh
Please set the password for root here.
New password:
Re-enter new password:
79, sửa đổi bằng lệnh Please set the password for root here.
New password:
Re-enter new password:
80 và truy xuất bằng lệnh Please set the password for root here.
New password:
Re-enter new password:
82. Tất nhiên, MySQL có thể thực hiện các hoạt động thậm chí rất phức tạp. Xem qua hướng dẫn về MySQL để bắt đầu và tham khảo tài liệu về MySQL để có cái nhìn tổng quan đầy đủThêm thông tin
Bạn có thể muốn tham khảo các tài nguyên sau để biết thêm thông tin về chủ đề này. Mặc dù chúng được cung cấp với hy vọng rằng chúng sẽ hữu ích, xin lưu ý rằng chúng tôi không thể đảm bảo tính chính xác hoặc kịp thời của các tài liệu được lưu trữ bên ngoài