0 n mysql

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

Hệ thống quản lý cơ sở dữ liệu quan hệ phổ biến (RDBMS) bao gồm

  • Oracle thương mại, IBM DB2, Microsoft SQL Server và Access, SAP Hana
  • mã nguồn mở MySQL, PostgreSQL, mariaDB, Embedded Apache Derby (Java DB), mSQL (mini-SQL), SQLite, Apache OpenOffice's Base và mongoDB (không liên quan)

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: xxxxxxxx
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: xxxxxxxx
7,
// 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: xxxxxxxx
8,
// 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: xxxxxxxx
9,
-- 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

  1. Một hệ cơ sở dữ liệu quan hệ chứa nhiều cơ sở dữ liệu
  2. Một cơ sở dữ liệu bao gồm các bảng
  3. Một bảng có hàng (hoặc bản ghi) và cột (hoặc trường)

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: xxxxxxxx
51 (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: xxxxxxxx
7

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: xxxxxxxx
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: xxxxxxxx
7,
// 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: xxxxxxxx
9,
// 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: xxxxxxxx
8) để tương tác với hệ thống cơ sở dữ liệu quan hệ

LỰA CHỌN
XÓA BỎ
CHÈN
CẬP NHẬT
TẠO BẢNG
THẢ BÀN
ghi chú
  1. phân biệt chữ hoa chữ thường. Từ khóa SQL, tên (số nhận dạng), chuỗi có thể hoặc không phân biệt chữ hoa chữ thường, tùy thuộc vào việc triển khai
    • Trong MySQL, các từ khóa KHÔNG phân biệt chữ hoa chữ thường. Để rõ ràng, tôi hiển thị các từ khóa bằng chữ HOA trong bài viết này
    • Đối với các lập trình viên, cách tốt nhất là coi tên (mã định danh) và chuỗi là phân biệt chữ hoa chữ thường.
      (Trong MySQL, tên cột luôn phân biệt chữ hoa chữ thường; nhưng tên bảng phân biệt chữ hoa chữ thường trong Unix, nhưng phân biệt chữ hoa chữ thường trong Windows (nhầm lẫn. ). Phân biệt chữ hoa chữ thường trong so sánh chuỗi phụ thuộc vào trình tự đối chiếu được sử dụng (?. ). )
  2. Sợi dây. Các chuỗi SQL được đặt trong dấu nháy đơn. Nhưng hầu hết các triển khai (chẳng hạn như MySQL) đều chấp nhận cả dấu ngoặc đơn và dấu ngoặc kép

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ó là nguồn mở và miễn phí (có nhiều cơ sở dữ liệu 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

0 n mysql

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

MariaDB

Trí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 SQL

Tô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ạn

QUAN 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à

  • (Dành cho Windows) "
    // 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: xxxxxxxx
    57"
  • (Đối với macOS/Linux) "______158" 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: xxxxxxxx
    59" biểu thị thư mục chính của bạ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: xxxxxxxx
5

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 MySQL

Cho cửa sổ

  1. Tải xuống Máy chủ Cộng đồng MySQL "ZIP ARCHIVE" từ https. // nhà phát triển. mysql. com/tải xuống/mysql/
    1. Trong tab "Bản phát hành có sẵn chung (GA)"
    2. Trong "Máy chủ cộng đồng MySQL 8. 0. {xx}", trong đó {xx} là số cập nhật mới nhất ⇒ Trong "Select Operating System", chọn "Microsoft Windows"
    3. Trong phần "Tải xuống khác", hãy tải xuống "Windows (x86, 64-bit), ZIP ARCHIVE (khoảng 200MB) (
      // 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: xxxxxxxx
      60)"
    4. Trong "Tải xuống cộng đồng MySQL", KHÔNG cần "Đăng nhập" hoặc "Đăng ký" - Chỉ cần nhấp vào "Không, cảm ơn, chỉ cần bắt đầu tải xuống của tôi. "
  2. Giải nén tệp đã tải xuống vào thư mục dự án của bạ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: xxxxxxxx
    61". MySQL sẽ được giải nén thà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: xxxxxxxx
    62". (Nhấp chuột phải vào tệp ⇒ Giải nén tất cả ⇒ Chọn thư mục đích 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: xxxxxxxx
    57". )
    Để DỄ SỬ DỤNG, chúng tôi sẽ rút ngắn và ĐỔI TÊN thư mục thà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: xxxxxxxx
    64". Hãy lưu ý và ghi nhớ thư mục cài đặt MySQL của bạn.
  3. (MỚI kể từ MySQL 5. 7. 7) Khởi tạo cơ sở dữ liệu. Bắt đầu CMD (với tư cách quản trị viên) (nút "Tìm kiếm" ⇒ Nhập "cmd" ⇒ Nhấp chuột phải vào "Dấu nhắc lệnh" ⇒ Chạy với tư cách Quản trị viên) và đưa ra các lệnh sau.
    // 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: xxxxxxxx
    Trong quá trình cài đặt, một siêu người dùng có tên 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: xxxxxxxx
    65 được tạo bằng một mật khẩu tạm thời, như minh họa ở trên. HÃY LƯU Ý MẬT KHẨU, SAO CHÉP và LƯU nó ở đâu đó; .
    LƯU Ý. Nếu lỗi "VCRUNTIME140_1. dll không tìm thấy" xảy ra, hãy kiểm tra TẠI ĐÂY.
  4. Nếu bạn nhập sai hoặc quên mật khẩu, hãy XÓA toàn bộ thư mục đã cài đặt 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: xxxxxxxx
    66" và LẶP LẠI bước 2 và 3

Đố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ữ

  1. Tải xuống Máy chủ cộng đồng MySQL "Lưu trữ DMG" từ https. // nhà phát triển. mysql. com/tải xuống/mysql/
    1. Trong tab "Bản phát hành có sẵn chung (GA)"
    2. Trong "Máy chủ cộng đồng MySQL 8. 0. {xx}", trong đó {xx} là số cập nhật mới nhất ⇒ Trong "Select Operating System", chọn "macOS"
    3. Chọn "macOS 11 (x86, 64-bit) DMG Archive" thích hợp cho macOS 11 hoặc 12 (
      // 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: xxxxxxxx
      67) (Nếu máy mac của bạn đang chạy trên bộ xử lý ARM (Apple M1), thì hãy chọn "macOS11 (ARM, 64-bit)
      • Để kiểm tra phiên bản hệ điều hành của bạn ⇒ Nhấp vào biểu tượng 'Apple' ⇒ "Giới thiệu về máy Mac này"
      • Để kiểm tra bộ xử lý của bạn ⇒ Nhấp vào biểu tượng 'Apple' ⇒ tìm "Intel" (x86);
      • Để kiểm tra xem macOS của bạn là 32-bit hay 64-bit ⇒ Đọc http. //ủng hộ. táo. com/kb/ht3696. Trừ khi bạn có một cỗ máy thời khủng long, nếu không thì nó phải là 64-bit
    4. KHÔNG cần phải "Đăng nhập" hoặc "Đăng ký" - Chỉ cần nhấp vào "Không, cảm ơn, chỉ cần bắt đầu tải xuống của tôi"
  2. Để cài đặt MySQL (Xem https. // nhà phát triển. mysql. com/doc/refman/8. 0/vi/osx-cài đặt-pkg. html cho ảnh chụp màn hình)
    1. Chuyển đến "Tải xuống" ⇒ Nhấp đúp vào tệp "
      // 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: xxxxxxxx
      68" đã tải xuống
    2. Nhấp đúp vào "
      // 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: xxxxxxxx
      69"
    3. Trong "Giới thiệu", nhấp vào "Tiếp tục"
    4. Trong "Giấy phép", chọn "Đồng ý"
    5. Trong "Loại cài đặt", nhấp vào "Cài đặt"
    6. Trong "Cấu hình", chọn "Sử dụng mã hóa mật khẩu mạnh" và nhập mật khẩu cho người dùng "root". Đảm bảo bạn nhớ mật khẩu của mình
    7. MySQL sẽ được cài đặt 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: xxxxxxxx
      70____371". Lưu ý thư mục đã cài đặt này
    8. Đẩy ra ". Tệp
      // 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: xxxxxxxx
      72"
  3. Nếu bạn nhập sai hoặc quên mật khẩu, hãy dừng máy chủ (Nhấp vào Biểu tượng "Apple" ⇒ Tùy chọn hệ thống ⇒ MySQL ⇒ Dừng).
    Goto
    // 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: xxxxxxxx
    73 (thông qua Finder ⇒ Go ⇒ GoTo Folder ⇒ gõ
    // 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: xxxxxxxx
    73) và xóa tất cả các thư mục bắt đầu 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: xxxxxxxx
    75", e. g. , "
    // 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: xxxxxxxx
    76" 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: xxxxxxxx
    71" và Chạy lại Bước 2.

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: xxxxxxxx
78" (đố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: xxxxxxxx
79" (đố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

0 n mysql
  1. 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, viết tắt của daemon - daemon là một quá trình không tương tác chạy trong nền)
  2. Chương trình khách hàng đượ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: xxxxxxxx
    71" (không 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)
    72)

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: xxxxxxxx
71 đượ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 động

Cho 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, không. Đọ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: xxxxxxxx
5

Đố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: xxxxxxxx
65" 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: xxxxxxxx
71". (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: xxxxxxxx
6

Đố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: xxxxxxxx
65

// 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: xxxxxxxx
7

(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: xxxxxxxx
65" 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: xxxxxxxx
65" 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ới

Chú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: xxxxxxxx
65 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: xxxxxxxx
65. 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ới

Siê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 bắt đầu ứ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: xxxxxxxx
65"

// 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: xxxxxxxx
50
Giải trình
  • TẠO NGƯỜI DÙNG 'myuser'@'localhost' ĐƯỢC XÁC ĐỊNH BỞI 'xxxx'
    Chúng tôi sử dụng lệ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)
    43" để tạo người dùng mới có 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)
    44, người này có thể đăng nhập vào máy chủ cục bộ .
  • CẤP TẤT CẢ BẬT *. * ĐẾN 'myuser'@'localhost'
    Người dùng mới được tạo KHÔNG có đặc quyền thực hiện bất kỳ thao tác cơ sở dữ liệu nào, kể 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)
    46. Chúng tôi sử dụng lệ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)
    47" để cấp "
    -- 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)
    48" các đặc quyền (bao gồm
    -- 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)
    46,
    // 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: xxxxxxxx
    500,
    // 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: xxxxxxxx
    501, v.v.) cho người dùng mới này trên TẤT CẢ các cơ sở dữ liệu và TẤT CẢ 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: xxxxxxxx
    502"). Trên thực tế, người dùng mới này có đặc quyền giống 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: xxxxxxxx
    65, ngoại trừ việc nó không thể ra lệ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)
    47. Đối với sản xuất, bạn chỉ nên cấp các đặc quyền cần thiết trên các cơ sở dữ liệu đã chọn và các bảng đã chọn, e. g. , "
    // 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: xxxxxxxx
    505,
    // 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: xxxxxxxx
    500,
    // 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: xxxxxxxx
    507" - nó chỉ có thể phát hà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)
    46,
    // 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: xxxxxxxx
    500 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: xxxxxxxx
    510 (nhưng không 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: xxxxxxxx
    501,
    // 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: xxxxxxxx
    512) trên TẤT CẢ các bảng của 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.

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ật

Nhớ lại rằng máy chủ MySQL tổ chức dữ liệu theo cấu trúc phân cấp sau

  1. Một hệ thống chứa nhiều cơ sở dữ liệu
  2. Một cơ sở dữ liệu chứa nhiều bảng
  3. Một bảng chứa các hàng (bản ghi) và cột (trường)

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: xxxxxxxx
51 - 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

  • Bạn cần kết thúc lệnh của mình bằng dấu chấm phẩ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: xxxxxxxx
    522), dấu chấm phẩy này sẽ gửi lệnh đến máy chủ để xử lý. e. g. ,
    // 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: xxxxxxxx
    51
  • Một lệnh có thể kéo dài nhiều dòng. Lời nhắc cho các dòng tiếp theo thay đổi thà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: xxxxxxxx
    523 ​​để biểu thị sự tiếp tục. Bạn cần kết thúc lệnh bằng dấu chấm phẩy (______2522). e. g. ,
    // 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: xxxxxxxx
    52Nói cách khác, nếu bạn quên gõ
    // 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: xxxxxxxx
    525, bạn có thể gõ
    // 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: xxxxxxxx
    525 ở dòng tiếp theo
  • Bạn có thể sử 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: xxxxxxxx
    527 để hủy (abort) lệnh hiện tại. e. g. ,
    // 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: xxxxxxxx
    53
  • Nếu bạn mở một trích dẫn đơn/đôi mà không đóng nó, lời nhắc tiếp tục sẽ thay đổi thà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: xxxxxxxx
    528 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: xxxxxxxx
    529 (thay 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: xxxxxxxx
    523). Ví dụ, ______254
  • Bạn cũng có thể nhấn Ctrl-C để hủy bỏ lệnh hiện tại
  • Bạn có thể sử dụng các phím mũi tên lên/xuống để truy xuất các lệnh trước đó/tiếp theo, từ "lịch sử lệnh"
  • (Đối với Windows 10) Bạn nên bật chức năng Copy/Paste của CMD shell. Để bật Sao chép/Dán, nhấp vào biểu tượng CMD ⇒ Thuộc tính ⇒ Tùy chọn ⇒ Chỉnh sửa tùy chọn ⇒ Kiểm tra "Bật phím tắt Ctrl". Sau đó, bạn có thể sử dụng Ctrl-C/Ctrl-V để Sao chép/Dán

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: xxxxxxxx
55
bài tập
  1. Chọn các bản ghi có tên bắt đầu bằng chữ cá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: xxxxxxxx
    532. (Gợ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: xxxxxxxx
    533, xem Phần "SQL theo ví dụ")
  2. Chọn các bản ghi có tên KHÔNG bắt đầu bằng chữ cá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: xxxxxxxx
    532. (Gợ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: xxxxxxxx
    535)
  3. Chọn các bản ghi 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)
    6 giữa 4. 35 và 4. 65. (Gợ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: xxxxxxxx
    537)
  4. Chọn các bản ghi có tên có chữ cá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: xxxxxxxx
    538. (Gợ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: xxxxxxxx
    539)
  5. Chọn các bản ghi có tên có chữ cá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: xxxxxxxx
    538 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: xxxxxxxx
    541. (Gợ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: xxxxxxxx
    542)
  6. Chọn các bản ghi có tên có chữ cá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: xxxxxxxx
    538 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: xxxxxxxx
    544

(Bỏ qua trừ khi. ) Đọc "Cách gỡ lỗi"

Bài tập khác

  1. Hiển thị tất cả các cơ sở dữ liệu
  2. Tạo cơ sở dữ liệu mới có tên "______2545"
  3. Đặt cơ sở dữ liệ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: xxxxxxxx
    545" làm cơ sở dữ liệu mặc định
  4. Hiển thị tất cả các bảng trong cơ sở dữ liệu mặc định
  5. Tạo một bảng mới 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: xxxxxxxx
    547" với các cột và loại được chỉ định bên dướ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: xxxxxxxx
    56
  6. Hiển thị mô tả bảng
  7. Chèn các bản ghi trên và liệt kê tất cả các bản ghi
  8. Liệt kê các bản ghi có tên chứa "______2548"
  9. Liệt kê các bản ghi có giá ≥ 1. 0
  10. Tăng giá của tất cả các mặt hàng lên 10% và liệt kê tất cả các bản ghi
  11. Xóa "Bút đỏ" khỏi bảng và liệt kê tất cả các bản ghi

Mối quan hệ nhiều-nhiều

Trong 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ỳ phần 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;

0 n mysql

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: xxxxxxxx
549 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: xxxxxxxx
551 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: xxxxxxxx
549 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: xxxxxxxx
550 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: xxxxxxxx
549 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: xxxxxxxx
550

0 n mysql
bài tập
  1. Tạo cơ sở dữ liệu 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: xxxxxxxx
    556"
  2. Sử 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: xxxxxxxx
    556" làm cơ sở dữ liệu mặc định
  3. Tạo 3 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: xxxxxxxx
    549", "______2550" 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: xxxxxxxx
    551" trong cơ sở dữ liệ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: xxxxxxxx
    556", với tên và loại cột như trong sơ đồ cơ sở dữ liệu
  4. Chèn các bản ghi tương ứng vào các bảng và liệt kê nội dung của từng bảng
  5. Hãy thử truy vấn này và giải thích đầu ra.
    // 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: xxxxxxxx
    57
  6. Hãy thử truy vấn này và quan sát cách nối 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: xxxxxxxx
    58
  7. Liệt kê tất cả các cuốn sá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: xxxxxxxx
    562,
    // 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: xxxxxxxx
    563,
    // 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: xxxxxxxx
    564) của "Tan Ah Teck" vớ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: xxxxxxxx
    563 ít hơ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: xxxxxxxx
    566
  8. Liệt kê tất cả các tác giả (
    -- 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: xxxxxxxx
    568) cho tựa sách "Java cho Dummies"
  9. Liệt kê tất cả các cuốn sá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: xxxxxxxx
    562,
    // 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: xxxxxxxx
    563,
    // 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: xxxxxxxx
    564) và tất cả các tác giả (
    -- 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: xxxxxxxx
    568) cho những cuốn sách có tựa đề bắt đầu bằng "Java" (Gợ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: xxxxxxxx
    574)

(Tùy chọn) Sao lưu và khôi phục cơ sở dữ liệu

Sao 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: xxxxxxxx
575 để 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: xxxxxxxx
576" 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: xxxxxxxx
578"

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: xxxxxxxx
59

Đố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: xxxxxxxx
0

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: xxxxxxxx
579,
-- 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: xxxxxxxx
7 để 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 mysql

Bạ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: xxxxxxxx
582" 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: xxxxxxxx
1

Đố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: xxxxxxxx
2

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 MySQL
Các lệnh MySQL thường được sử dụng

Cá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

GÂY RA. 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

DUNG DỊCH. Xem "Bản tải xuống Visual C++ được hỗ trợ mới nhất" @ https. //ủng hộ. 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: xxxxxxxx
584" ⇒ 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: xxxxxxxx
585" 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: xxxxxxxx
586"