Đường dẫn mysql mac
Trong bài viết này mình sẽ hướng dẫn các bạn cách cài đặt MySQL Community Server trên macOS các bạn nhé Show Cài đặtĐầu tiên, các bạn cần phải truy cập địa chỉ https. // nhà phát triển. mysql. com/downloads/mysql/ để tải xuống tập tin cài đặt của MySQL dành cho macOS Có nhiều lựa chọn khác nhau, nhưng các bạn nên chọn tập tin. dmg to install because it has an interface, will easy more Sau khi tải về xong, hãy nhấp vào tập tin tải xuống để bắt đầu cài đặt MySQL các bạn nhé 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à
// For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject 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. 32) hoạt động với macOS Monterey (12) và Ventura (13). 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 the current directory to MySQL's binary directory. cd /usr/local/mysql/bin -- Start a client with superuser "root" (-u), and prompt for password (-p) ./mysql -u root -p Enter password: // Enter the root's password given during installation. You will NOT any * for maximum security Welcome to the MySQL monitor. Commands end with ; or \g. ...... mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.9" (đối với Windows) hoặc " -- Change password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye0" (đố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 password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye1 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 password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye2 và -- Change the current directory to MySQL's binary directory. cd /usr/local/mysql/bin -- Start a client with superuser "root" (-u), and prompt for password (-p) ./mysql -u root -p Enter password: // Enter the root's password given during installation. You will NOT any * for maximum security Welcome to the MySQL monitor. Commands end with ; or \g. ...... mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.2 được giữ trong thư mục con " -- Change password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye8" 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye9 hướng các thông báo đầu ra tới bảng đ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 "" 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 XXXXXX XX:XX:XX [Note] mysqld: Normal shutdown ...... XXXXXX XX:XX:XX InnoDB: Starting shutdown... XXXXXX XX:XX:XX InnoDB: Shutdown completed; log sequence number 0 44233 ...... XXXXXX XX:XX:XX [Note] mysqld: Shutdown complete (You may need to press ENTER to get the command prompt?!) Đố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 password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye2" 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 the current directory to MySQL's binary directory. -- Assume that the MySQL is installed in "c:\myWebProject\mysql". c: cd \myWebProject\mysql\bin -- Start a client as superuser "root" (-u), and prompt for password (-p) mysql -u root -p Enter password: // Enter the root's password set during installation. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 8.0.xx Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.5" 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 một chương trình máy khách dòng lệnh có tên " -- Change the current directory to MySQL's binary directory. cd /usr/local/mysql/bin -- Start a client with superuser "root" (-u), and prompt for password (-p) ./mysql -u root -p Enter password: // Enter the root's password given during installation. You will NOT any * for maximum security Welcome to the MySQL monitor. Commands end with ; or \g. ...... mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.2". (Hãy nhớ rằng chương trình máy chủ được gọi là " -- Change password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye2" với hậu tố -- Change password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye3; chương trình máy khách không có hậu tố ' -- Change directory to MySQL's binary directory c: cd \myWebProject\mysql\bin -- Start a MySQL client mysql -u root -p Enter password: // Enter the NEW password Welcome to the MySQL monitor. ..... mysql> -- client started, ready to issue SQL command5') Hãy bắt đầu một ứng dụng khách dòng lệnh với siêu người dùng "______26_______5" 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 the current directory to MySQL's binary directory. -- Assume that the MySQL is installed in "c:\myWebProject\mysql". c: cd \myWebProject\mysql\bin -- Start a client as superuser "root" (-u), and prompt for password (-p) mysql -u root -p Enter password: // Enter the root's password set during installation. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 8.0.xx Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE. Đố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 the current directory to MySQL's binary directory. -- Assume that the MySQL is installed in "c:\myWebProject\mysql". c: cd \myWebProject\mysql\bin -- Start a client as superuser "root" (-u), and prompt for password (-p) mysql -u root -p Enter password: // Enter the root's password set during installation. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 8.0.xx Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.5 -- Change the current directory to MySQL's binary directory. cd /usr/local/mysql/bin -- Start a client with superuser "root" (-u), and prompt for password (-p) ./mysql -u root -p Enter password: // Enter the root's password given during installation. You will NOT any * for maximum security Welcome to the MySQL monitor. Commands end with ; or \g. ...... mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE. (Bỏ qua trừ khi. ) Đọc "" 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 the current directory to MySQL's binary directory. -- Assume that the MySQL is installed in "c:\myWebProject\mysql". c: cd \myWebProject\mysql\bin -- Start a client as superuser "root" (-u), and prompt for password (-p) mysql -u root -p Enter password: // Enter the root's password set during installation. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 8.0.xx Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.5" với một mật khẩu ngẫu nhiên tạm thời. "______26_______5" 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 password for 'root'@'localhost'. Replace xxxx with your chosen password -- (For macOS, there is no need to change the password, but there is no harm trying it out) -- (For my students: use xxxx as the password. Otherwise, you will ask me what is your password next week.) -- Take note that strings are to be enclosed by a pair of single-quotes in MySQL. mysql> alter user 'root'@'localhost' identified by 'xxxx'; Query OK, 0 rows affected (0.00 sec) -- Query the password mysql> select Host, User, authentication_string from mysql.user; +-----------+------------------+---------------------------+ | Host | User | authentication_string | +-----------+------------------+---------------------------+ | localhost | root | $A$005... | | ... | ... | ....... | +-----------+------------------+---------------------------+ -- Take note that the "HASH" of the password is saved, NOT the "PLAIN" password -- [Starting from MySQL 5.x, the "Password" field was removed?!] -- logout and terminate the client program mysql> quit Bye 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 the current directory to MySQL's binary directory. -- Assume that the MySQL is installed in "c:\myWebProject\mysql". c: cd \myWebProject\mysql\bin -- Start a client as superuser "root" (-u), and prompt for password (-p) mysql -u root -p Enter password: // Enter the root's password set during installation. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 8.0.xx Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.5 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 the current directory to MySQL's binary directory. -- Assume that the MySQL is installed in "c:\myWebProject\mysql". c: cd \myWebProject\mysql\bin -- Start a client as superuser "root" (-u), and prompt for password (-p) mysql -u root -p Enter password: // Enter the root's password set during installation. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 8.0.xx Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.5. Nhập mật khẩu khi được nhắc Cho cửa sổ -- Change directory to MySQL's binary directory c: cd \myWebProject\mysql\bin -- Start a MySQL client mysql -u root -p Enter password: // Enter the NEW password Welcome to the MySQL monitor. ..... mysql> -- client started, ready to issue SQL command Đối với macOS -- Change directory to MySQL's binary directory cd /usr/local/mysql/bin -- Start a MySQL client ./mysql -u root -p Enter password: // Enter the NEW password Welcome to the MySQL monitor. ...... mysql> -- client started, ready to issue SQL command 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à " -- Change directory to MySQL's binary directory cd /usr/local/mysql/bin -- Start a MySQL client ./mysql -u root -p Enter password: // Enter the NEW password Welcome to the MySQL monitor. ...... mysql> -- client started, ready to issue SQL command2" - 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 the current directory to MySQL's binary directory. -- Assume that the MySQL is installed in "c:\myWebProject\mysql". c: cd \myWebProject\mysql\bin -- Start a client as superuser "root" (-u), and prompt for password (-p) mysql -u root -p Enter password: // Enter the root's password set during installation. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 8.0.xx Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Client started. The prompt changes to "mysql>". -- You can now issue SQL commands such as SELECT, INSERT and DELETE.5" // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject0 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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ự), -- 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... XXXXXX XX:XX:XX [Note] mysqld: ready for connections. Version: '8.0.xx' socket: '' port: 3306 MySQL Community Server (GPL)6 (kiểu XXXXXX XX:XX:XX [Note] mysqld: Normal shutdown ...... XXXXXX XX:XX:XX InnoDB: Starting shutdown... XXXXXX XX:XX:XX InnoDB: Shutdown completed; log sequence number 0 44233 ...... XXXXXX XX:XX:XX [Note] mysqld: Shutdown complete (You may need to press ENTER to get the command prompt?!)1 - 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 Mẹo sử dụng 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 "_______75_______2" // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject5 bài tập
(Bỏ qua trừ khi. ) Đọc "" 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ỳ 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; 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 // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject50 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 là // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject52 tham gia các bảng // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject50 và // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject51 và nắm bắt mối quan hệ nhiều-nhiều giữa // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject50 và // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject51 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 // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject76 để 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 "_______25_______77" 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 "_______4_______2" vào tập lệnh SQL có tên " // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject79" Cho cửa sổ // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject9 Đố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 // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject80, -- 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 " // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject83" 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 // If Windows Defender Firewall popup, choose "allow access". ...... ...... 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 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. // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject85" ⇒ 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 " // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject86" trong " // For Windows: Use "C:\myWebProject" // Launch a "CMD" and issue these commands: c: cd \ mkdir myWebProject // For macOS: Use "~/myWebProject" (where "~" denotes your home directory) // Launch a "Terminal" and issue these commands: cd mkdir myWebProject87" |