Một cơ sở dữ liệu quan hệ tổ chức dữ liệu trong các bảng. Một bảng có hàng (hoặc bản ghi) và cột (hoặc trường). Các bảng có liên quan dựa trên các cột chung để loại bỏ sự dư thừa dữ liệu và đảm bảo tính toàn vẹn của dữ liệu Show
Hệ thống quản lý cơ sở dữ liệu quan hệ phổ biến (RDBMS) bao gồm
Ngôn ngữ truy vấn cấu trúc (SQL)Ngôn ngữ lập trình cấp cao, được gọi là Ngôn ngữ truy vấn cấu trúc (SQL), được thiết kế để tương tác với cơ sở dữ liệu quan hệ. SQL định nghĩa một tập hợp các lệnh, chẳng hạn như // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx6, // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx7, // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx8, // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx9, -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)0, -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)1, v.v. Edgar F. Codd của IBM đã đề xuất Mô hình cơ sở dữ liệu quan hệ vào năm 1970. SQL, một trong những ngôn ngữ lập trình trước đó, sau đó được phát triển bởi Donald D. Chamberlin và Raymond F. Boyce tại IBM vào đầu những năm 1970. Oracle, sau đó, đã đưa nó lên một tầm cao mới ANSI (Viện Tiêu chuẩn Quốc gia Hoa Kỳ) đã thiết lập tiêu chuẩn SQL đầu tiên vào năm 1986 (SQL-86 hoặc SQL-87) - được ISO/IEC thông qua là "ISO/IEC 9075" - tiếp theo vào năm 1989 (SQL-89), 1992 (SQL- . 2003), 2006 (SQL. 2006), 2011 (SQL. 2011) và 2016 (SQL. 2016). Tuy nhiên, hầu hết các nhà cung cấp cơ sở dữ liệu đều có hướng dẫn riêng của họ, chẳng hạn như. g. , PL/SQL (Oracle), Transact-SQL (Microsoft, SAP), PL/pgSQL (PostgreSQL) SQL theo ví dụMột hệ thống cơ sở dữ liệu quan hệ tổ chức dữ liệu theo thứ bậc sau
Giả sử chúng ta có một cơ sở dữ liệu tên là -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)2, một bảng tên là -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)3 trong cơ sở dữ liệu có 3 cột ( -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)4, -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)5, -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)6) và 4 hàng như minh họa bên dưới. Mỗi cột có một kiểu dữ liệu. Chúng tôi chọn. -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)7 (số nguyên) cho cột -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)4, -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)9 (chuỗi có độ dài thay đổi tối đa 50 ký tự) cho -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)5 và // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx51 (số dấu phẩy động) cho -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)6 // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx7 SQL (Structure Query Language) định nghĩa một tập hợp các lệnh trực quan (chẳng hạn như // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx6, // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx7, // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx9, // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx8) để tương tác với hệ thống cơ sở dữ liệu quan hệ LỰA CHỌNXÓA BỎCHÈNCẬP NHẬTTẠO BẢNGTHẢ BÀNghi chú
Giới thiệu về Hệ thống quản lý cơ sở dữ liệu quan hệ MySQL (RDBMS)SQL là ngôn ngữ lập trình để tương tác với cơ sở dữ liệu quan hệ. Mặt khác, MySQL là một phần mềm - Hệ quản trị cơ sở dữ liệu quan hệ MySQL là một trong những Hệ thống quản lý cơ sở dữ liệu quan hệ (RDBMS) miễn phí, mã nguồn mở và được sử dụng nhiều nhất. MySQL được phát triển bởi Michael "Monty" Widenius và David Axmark vào năm 1995. Nó thuộc sở hữu của một công ty Thụy Điển tên là MySQL AB, được Sun Microsystems mua lại vào năm 2008. Sun Microsystems đã được Oracle mua lại vào năm 2010 MySQL thành công, không chỉ vì nó miễn phí và mã nguồn mở (có nhiều cơ sở dữ liệu mã nguồn mở và miễn phí, chẳng hạn như PostgreSQL, Apache Derby (Java DB), mSQL (mini SQL), SQLite và Cơ sở của Apache OpenOffice), mà còn . MySQL hỗ trợ tất cả các tính năng được mong đợi trong cơ sở dữ liệu quan hệ hiệu suất cao, chẳng hạn như giao dịch, khóa ngoại, sao chép, truy vấn phụ, thủ tục được lưu trữ, chế độ xem và trình kích hoạt MySQL thường được triển khai trong môi trường LAMP (Linux-Apache-MySQL-PHP), WAMP (Windows-Apache-MySQL-PHP) hoặc MAMP (macOS-Apache-MySQL-PHP). Tất cả các thành phần trong LAMP đều miễn phí và mã nguồn mở, bao gồm cả Hệ điều hành Trang mẹ của MySQL là https. //www. mysql. com. Tài liệu tham khảo cuối cùng cho MySQL là "Hướng dẫn tham khảo MySQL", có sẵn tại https. // nhà phát triển. mysql. com/doc. Hướng dẫn tham khảo rất lớn - PDF có hơn 3700 trang MySQL hoạt động như một hệ thống client-server qua mạng TCP/IP. Máy chủ chạy trên máy có địa chỉ IP trên số cổng TCP đã chọn. Số cổng TCP mặc định cho MySQL là 3306. Người dùng có thể truy cập máy chủ thông qua chương trình máy khách, kết nối với máy chủ theo địa chỉ IP và số cổng TCP đã cho MariaDBTrích từ Wiki. MariaDB là một ngã ba do cộng đồng phát triển, được hỗ trợ thương mại của hệ thống quản lý cơ sở dữ liệu quan hệ MySQL (RDBMS), nhằm duy trì phần mềm nguồn mở và miễn phí theo Giấy phép Công cộng GNU. Quá trình phát triển được dẫn dắt bởi một số nhà phát triển ban đầu của MySQL, người đã rẽ nhánh nó do lo ngại về việc bị Tập đoàn Oracle mua lại vào năm 2009 Cách cài đặt MySQL 8. 0 và Bắt đầu với Lập trình SQLTôi muốn bạn cài đặt MySQL trên máy của riêng bạn, vì tôi muốn bạn học cách cài đặt, tùy chỉnh và vận hành hệ thống phần mềm công nghiệp phức tạp. Cài đặt có thể là phần khó nhất trong bài tập này Bước 0. Tạo một thư mục để lưu giữ tất cả các tác phẩm của bạnQUAN TRỌNG. Trước khi bắt đầu, hãy kiểm tra xem bạn có vài GB dung lượng trống không Tạo một thư mục để giữ tất cả các tác phẩm của bạn được gọi là
// Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx5 Sử dụng giao diện đồ họa của bạn, e. g. , File Explorer (Windows) hoặc Finder (macOS) để xác minh thư mục này. (Tất nhiên bạn có thể sử dụng giao diện đồ họa của mình để tạo thư mục này. ) cho người mới. Điều quan trọng là phải làm theo bước này. Nếu không, bạn sẽ không đồng bộ với bài viết này và sẽ không thể tìm thấy tệp của mình sau này Bước 1. Tải xuống và cài đặt MySQLCho cửa sổ
Đối với macOS ghi chú. Phiên bản mới nhất của MySQL (8. 0. 28) hoạt động với macOS Big Sur (11) và Monterey (12). Nếu bạn đang chạy phiên bản macOS cũ hơn, bạn có thể cần tìm phiên bản lưu trữ của MySQL @ https. // nhà phát triển. mysql. com/downloads/ ⇒ Lưu trữ
Tôi sẽ giả sử rằng MySQL được cài đặt trong thư mục // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx78" (đối với Windows) hoặc " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx79" (đối với macOS). Nhưng bạn cần LƯU Ý THƯ MỤC CÀI ĐẶT MySQL CỦA BẠN. Sau đây, tôi sẽ biểu thị thư mục cài đặt MySQL là -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)70 trong bài viết này Bước 3. Bắt đầu "Máy chủ"MySQL là một hệ thống client-server. Cơ sở dữ liệu được chạy như một ứng dụng máy chủ. Người dùng truy cập máy chủ cơ sở dữ liệu thông qua chương trình máy khách, cục bộ hoặc từ xa qua mạng, như minh họa
Các chương trình -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)71 và // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx71 được giữ trong thư mục con " -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)77" của thư mục cài đặt MySQL Máy chủ khởi độngCho cửa sổ Để khởi động máy chủ cơ sở dữ liệu, hãy khởi chạy trình bao CMD mới -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL) Ghi chú. Tùy chọn -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)78 hướng các thông báo đầu ra tới bàn điều khiển. Nếu không có tùy chọn này, bạn sẽ thấy một màn hình trống Đối với macOS CÁCH DỄ DÀNG. Thông qua điều khiển đồ họa. Nhấp vào Biểu tượng "Apple" ⇒ Tùy chọn hệ thống ⇒ MySQL ⇒ Bắt đầu hoặc Dừng Máy chủ cơ sở dữ liệu MySQL hiện đã bắt đầu và sẵn sàng xử lý các yêu cầu của khách hàng Bất cứ điều gì có thể đi sai, làm. Đọc "Cách gỡ lỗi" Tắt máy chủCho cửa sổ Cách nhanh nhất để tắt máy chủ cơ sở dữ liệu là nhấn Ctrl-C để bắt đầu tắt máy bình thường. KHÔNG GIẾT máy chủ thông qua nút ĐÓNG của cửa sổ Quan sát các thông báo này từ bảng điều khiển máy chủ MySQL // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx5 Đối với macOS CÁCH DỄ DÀNG. Thông qua điều khiển đồ họa. Nhấp vào Biểu tượng "Apple" ⇒ Tùy chọn hệ thống ⇒ MySQL ⇒ Dừng CẢNH BÁO. Bạn nên tắt máy chủ MySQL đúng cách. Nếu không, bạn có thể làm hỏng cơ sở dữ liệu và có thể gặp sự cố khi khởi động lại nó. NHƯNG, nếu bạn gặp sự cố khi tắt máy chủ bình thường, bạn có thể tắt quy trình " -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)71" trong Trình quản lý tác vụ (dành cho Windows); Bước 4. Bắt đầu một "Khách hàng"Nhớ lại rằng MySQL là một hệ thống máy khách-máy chủ. Khi máy chủ được khởi động, một hoặc nhiều máy khách có thể được kết nối với máy chủ cơ sở dữ liệu. Một máy khách có thể chạy trên cùng một máy (máy khách cục bộ); Để đăng nhập vào máy chủ MySQL, bạn cần cung cấp tên người dùng và mật khẩu. Trong quá trình cài đặt, MySQL tạo một siêu người dùng có tên " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx65" với mật khẩu tạm thời. Tôi hy vọng rằng bạn đã lưu ý mật khẩu này. (Nếu không, hãy cài đặt lại. ) Cài đặt MySQL cung cấp chương trình máy khách dòng lệnh có tên " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx71". (Hãy nhớ rằng chương trình máy chủ được gọi là " -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)71" với hậu tố -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)72; chương trình máy khách không có hậu tố ' -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)34') Hãy bắt đầu một ứng dụng khách dòng lệnh với siêu người dùng "______265" Trước tiên, hãy đảm bảo rằng máy chủ đang chạy. Xem bước trước để khởi động lại máy chủ nếu nó đã bị tắt Cho cửa sổ Bắt đầu Shell CMD MỚI khác để chạy máy khách (Bạn cần giữ CMD chạy máy chủ) // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx6 Đối với macOS Mở một "Terminal" MỚI và đưa ra các lệnh này để khởi động ứng dụng khách MySQL với siêu người dùng // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx65 // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx7 (Bỏ qua trừ khi. ) Đọc "Cách gỡ lỗi" Bước 5. Thay đổi mật khẩu cho Superuser "root"Như đã đề cập trước đó, quá trình cài đặt MySQL tạo một siêu người dùng có tên " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx65" với một mật khẩu ngẫu nhiên tạm thời. " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx65" là người dùng đặc quyền có thể làm bất cứ điều gì, kể cả xóa tất cả cơ sở dữ liệu. Bạn được yêu cầu thay đổi mật khẩu của root ngay sau khi đăng nhập ghi chú. Nếu bạn gặp khó khăn khi nhập lệnh, hãy nhấn Ctrl-C để hủy bỏ lệnh hiện tại Thay đổi mật khẩu cho "root"Hãy tiếp tục với phiên khách hàng của chúng tôi đã bắt đầu trước đó -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)7 Khởi động lại Máy khách với tư cách "root" bằng Mật khẩu mớiChúng tôi vừa thay đổi mật khẩu cho // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx65 và thoát khỏi ứng dụng khách. Bắt đầu một ứng dụng khách và đăng nhập lại với tên // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx65. Nhập mật khẩu khi được nhắc Cho cửa sổ -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)3 Đối với macOS -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)4 Bước 6. Tạo người dùng mớiSiêu người dùng "root" là đặc quyền, dành cho quản trị cơ sở dữ liệu và không dành cho hoạt động. Chúng tôi sẽ tạo một người dùng mới - hãy gọi nó là "______741" - với đặc quyền thấp hơn. Để tạo người dùng mới, hãy khởi động ứng dụng khách với siêu người dùng " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx65" // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx50 Giải trình
Bước 7. Tạo Cơ sở dữ liệu mới, Bảng mới trong Cơ sở dữ liệu, Chèn Bản ghi, Truy vấn và Cập nhậtNhớ lại rằng máy chủ MySQL tổ chức dữ liệu theo cấu trúc phân cấp sau
Hãy tạo một cơ sở dữ liệu có tên " -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)2" và một bảng có tên " -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)3" trong cơ sở dữ liệu. Bảng sẽ có ba cột. -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)4 (kiểu -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)7 - số nguyên), -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)5 (kiểu -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)9 - chuỗi có độ dài thay đổi lên đến 50 ký tự), -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)6 (kiểu // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx51 - số dấu phẩy động) THẬN TRỌNG. Lập trình viên không sử dụng ký tự trống và ký tự đặc biệt trong NAM (tên cơ sở dữ liệu, tên bảng, tên cột). Nó không được hỗ trợ hoặc sẽ đặt ra cho bạn nhiều thử thách hơn Lời khuyên về phiên của khách hàng (Hãy quay lại phần này nếu bạn gặp khó khăn khi chạy lệnh)Trước khi chúng tôi tiếp tục, đây là một số mẹo sử dụng ứng dụng khách
Hãy bắt đầu một ứng dụng khách với người dùng mới được tạo của chúng tôi "______741" // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx55 bài tập
(Bỏ qua trừ khi. ) Đọc "Cách gỡ lỗi" Bài tập khác
Mối quan hệ nhiều-nhiềuTrong hiệu sách, một cuốn sách được viết bởi một hoặc nhiều tác giả; . Đây được gọi là mối quan hệ nhiều-nhiều. KHÔNG THỂ nắm bắt được mối quan hệ nhiều-nhiều trong một bảng DUY NHẤT (hoặc một bảng tính) với một số cột cố định mà không sao chép bất kỳ thông tin nào. Ví dụ: nếu bạn tổ chức dữ liệu trong bảng dưới đây, bạn sẽ không biết có bao nhiêu cột tác giả sẽ được sử dụng; Mối quan hệ nhiều-nhiều giữa sách và tác giả có thể được mô hình hóa bằng 3 bảng, như hình bên dưới. Bảng // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx549 chứa dữ liệu về sách (chẳng hạn như tên sách và giá); . Một bảng có tên // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx551 tham gia các bảng // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx549 và // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx550 và nắm bắt mối quan hệ nhiều-nhiều giữa // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx549 và // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx550 bài tập
(Tùy chọn) Sao lưu và khôi phục cơ sở dữ liệuSao lưu thông qua chương trình tiện ích "mysqldump"Bạn có thể sử dụng chương trình tiện ích // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx575 để sao lưu (i) toàn bộ máy chủ (tất cả cơ sở dữ liệu), (ii) cơ sở dữ liệu được chọn hoặc (ii) bảng được chọn của cơ sở dữ liệu. Chương trình " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx576" tạo tập lệnh SQL mà sau này có thể được thực thi để tạo lại cơ sở dữ liệu, bảng và các hàng của chúng Ví dụ: lệnh sau sao lưu toàn bộ cơ sở dữ liệu " -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)2" vào tập lệnh SQL có tên " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx578" Cho cửa sổ // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx59 Đối với macOS // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx0 Nghiên cứu tệp đầu ra, chứa các câu lệnh // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx579, -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)0 và // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx7 để tạo lại cơ sở dữ liệu và các bảng đã kết xuất trước đó Khôi phục thông qua lệnh "nguồn" trong máy khách mysqlBạn có thể khôi phục từ bản sao lưu bằng cách chạy lệnh " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx582" trong máy khách MySQL. Ví dụ: để khôi phục bản sao lưu -- Change the current directory to MySQL's binary directory -- Assume that the MySQL installed directory is "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin -- Start the MySQL Database Server mysqld --console ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)2 trước đó Cho cửa sổ // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx1 Đối với macOS // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx2 Tóm tắt các lệnh thường dùng(Dành cho Windows) Khởi động Máy chủ và Máy khách MySQL(Đối với macOS) Khởi động Máy chủ và Máy khách MySQLCác lệnh MySQL thường được sử dụngCác lệnh MySQL KHÔNG phân biệt chữ hoa chữ thường (Bỏ qua trừ khi. ) Làm thế nào để gỡ lỗi?"Mọi thứ có thể sai sẽ sai. " Điều quan trọng nhất cần làm là tìm TIN NHẮN LỖI NGUYÊN NHÂN. Bạn không có "thời gian chạy có thể phân phối lại của Microsoft Visual C++" được yêu cầu GIẢI PHÁP. Xem "Bản tải xuống Visual C++ được hỗ trợ mới nhất" @ https. //hỗ trợ. Microsoft. com/en-gb/help/2977003/the-latest-supported-visual-c-downloads ⇒ Tải xuống "x64. // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx584" ⇒ chạy tệp thực thi để cài đặt "Microsoft Visual C++ 2015-2019 redistributable (x64)" ⇒ Khởi động lại máy tính của bạn ⇒ Bạn có thể tìm thấy " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx585" trong " // Change directory to the MySQL's binary directory // Suppose that your MySQL is installed in "c:\myWebProject\mysql" c: cd \myWebProject\mysql\bin // Initialize the database. Create a root user with random password. Show the messages on console mysqld --initialize --console ...... ..... [Note] A temporary password is generated for root@localhost: xxxxxxxx586" Các yêu cầu để sử dụng MySQL trên máy tính của bạn là gì?Yêu cầu cài đặt
. Microsoft . NET Framework 4. 5. 2 trở lên . Nếu phiên bản này chưa được cài đặt trên máy chủ, bạn có thể tải xuống bằng cách truy cập trang web của Microsoft.
Công cụ nào được sử dụng cho MySQL?MySQL Workbench là công cụ trực quan hợp nhất dành cho kiến trúc sư cơ sở dữ liệu, nhà phát triển và DBA. MySQL Workbench cung cấp mô hình hóa dữ liệu, phát triển SQL và các công cụ quản trị toàn diện để cấu hình máy chủ, quản trị người dùng, sao lưu, v.v. MySQL Workbench khả dụng trên Windows, Linux và Mac OS X.
Làm cách nào để chạy MySQL trong Windows?Giải nén kho lưu trữ cài đặt Tạo một tệp tùy chọn Chọn loại máy chủ MySQL Khởi tạo thư mục dữ liệu Khởi động máy chủ lần đầu tiên Khởi động MySQL từ Dòng lệnh Windows Tùy chỉnh PATH cho Công cụ MySQL Khởi động MySQL dưới dạng Dịch vụ Windows Chúng tôi có thể chạy MySQL mà không cần Internet không?Đã trả lời gốc. Việc sử dụng cơ sở dữ liệu SQL có yêu cầu kết nối Internet không? . Bạn có thể thiết lập môi trường máy chủ cục bộ trên máy tính của mình -- Tôi sử dụng MAMP. Nó đi kèm với Apache, php và MySQL được cài đặt trên đó. No. You can setup a local server environment on your computer -- I use MAMP. It comes with Apache, php and MySQL installed on it. |