【MySQL學習】在RHEL7.3上使用yum安裝MySQL5.7

来源:https://www.cnblogs.com/rakas/archive/2018/03/16/8574123.html
-Advertisement-
Play Games

一、環境 二、官方源 獲取官方源: 安裝: 安裝之後, /etc/yum.repos.d/目錄下會產生兩個文件:mysql-community-source.repo、mysql-community.repo。 三、創建組和用戶 四、安裝MySQL 由於RHEL7.3中預設安裝了Mariadb,安裝 ...


一、環境

[root@rhel:~]#cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.3 (Maipo)
[root@rhel:~]#uname -r
3.10.0-514.el7.x86_64    
[root@rhel:~]#getenforce
Disabled

二、官方源

獲取官方源:

[root@rhel:/opt]#wget http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
--2018-03-15 15:25:41--  http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.55.208.125
Connecting to repo.mysql.com (repo.mysql.com)|23.55.208.125|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9224 (9.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-9.noarch.rpm’

100%[================================>] 9,224       1.80KB/s   in 5.0s   

2018-03-15 15:25:47 (1.80 KB/s) - ‘mysql57-community-release-el7-9.noarch.rpm’ saved [9224/9224]

安裝:

[root@rhel:/opt]#rpm -ivh mysql57-community-release-el7-9.noarch.rpm
warning: mysql57-community-release-el7-9.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql57-community-release-el7-9  ################################# [100%]

安裝之後, /etc/yum.repos.d/目錄下會產生兩個文件:mysql-community-source.repomysql-community.repo

三、創建組和用戶

[root@rhel:~]#groupadd mysql
[root@rhel:~]#useradd -r -g mysql -p root mysql
[root@rhel:~]#usermod -s /sbin/nologin mysql

四、安裝MySQL

由於RHEL7.3中預設安裝了Mariadb,安裝MySQL時會報錯,所以先卸載Mariadb。

[root@rhel:~]#rpm -qa|grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
mariadb-5.5.52-1.el7.x86_64
mariadb-server-5.5.52-1.el7.x86_64

卸載:

[root@rhel:~]#rpm -e mariadb-libs-5.5.52-1.el7.x86_64
error: Failed dependencies:
    libmysqlclient.so.18()(64bit) is needed by (installed) perl-DBD-MySQL-4.023-5.el7.x86_64
    libmysqlclient.so.18()(64bit) is needed by (installed) qt-mysql-1:4.8.5-13.el7.x86_64
    libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
    libmysqlclient.so.18()(64bit) is needed by (installed) zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64
    libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) perl-DBD-MySQL-4.023-5.el7.x86_64
    libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) qt-mysql-1:4.8.5-13.el7.x86_64
    libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
    libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64
    mariadb-libs(x86-64) = 1:5.5.52-1.el7 is needed by (installed) mariadb-1:5.5.52-1.el7.x86_64
    mariadb-libs(x86-64) = 1:5.5.52-1.el7 is needed by (installed) mariadb-server-1:5.5.52-1.el7.x86_64

使用--nodeps強制卸載:

[root@rhel:~]#rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
[root@rhel:~]#rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64
[root@rhel:~]#rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64

安裝MySQL:

[root@rhel:~]#yum install mysql-server
Loaded plugins: aliases, changelog, langpacks, ovl, product-id, search-
              : disabled-repos, subscription-manager, tmprepo, verify,
              : versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /mnt/cdrom/repodata/repomd.xml"
Trying other mirror.
mysql-connectors-community                         | 2.5 kB     00:00     
mysql-tools-community                              | 2.5 kB     00:00     
mysql57-community                                  | 2.5 kB     00:00     
zabbix                                             | 2.9 kB     00:00     
zabbix-non-supported                               |  951 B     00:00     
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.21-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.21-1.el7 for package: mysql-community-server-5.7.21-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.21-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.21-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.21-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.21-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.21-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================
 Package                 Arch    Version         Repository          Size
==========================================================================
Installing:
 mysql-community-server  x86_64  5.7.21-1.el7    mysql57-community  164 M
Installing for dependencies:
 mysql-community-client  x86_64  5.7.21-1.el7    mysql57-community   24 M
 mysql-community-common  x86_64  5.7.21-1.el7    mysql57-community  272 k
 mysql-community-libs    x86_64  5.7.21-1.el7    mysql57-community  2.1 M

Transaction Summary
==========================================================================
Install  1 Package (+3 Dependent packages)

Total size: 190 M
Total download size: 188 M
Installed size: 858 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for mysql57-community
warning: /var/cache/yum/x86_64/7Server/mysql57-community/packages/mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-client-5.7.21-1.el7.x86_64.rpm is not installed
(1/2): mysql-community-client-5.7.21-1.el7.x86_64.rp |  24 MB   00:05     
(2/2): mysql-community-server-5.7.21-1.el7.x86_64.rp | 164 MB   02:02     
--------------------------------------------------------------------------
Total                                        1.5 MB/s | 188 MB  02:02     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <[email protected]>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql57-community-release-el7-9.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 10 pre-existing rpmdb problem(s), 'yum check' output follows:
PackageKit-1.0.7-6.el7.x86_64 has missing requires of PackageKit-backend
akonadi-mysql-1.9.2-4.el7.x86_64 has missing requires of mariadb-server
perl-DBD-MySQL-4.023-5.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
perl-DBD-MySQL-4.023-5.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
1:qt-mysql-4.8.5-13.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
1:qt-mysql-4.8.5-13.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
  Installing : mysql-community-common-5.7.21-1.el7.x86_64             1/4 
  Installing : mysql-community-libs-5.7.21-1.el7.x86_64               2/4 
  Installing : mysql-community-client-5.7.21-1.el7.x86_64             3/4 
  Installing : mysql-community-server-5.7.21-1.el7.x86_64                                                                                                          4/4 
  Verifying  : mysql-community-server-5.7.21-1.el7.x86_64                                                                                                          1/4 
  Verifying  : mysql-community-common-5.7.21-1.el7.x86_64                                                                                                          2/4 
  Verifying  : mysql-community-libs-5.7.21-1.el7.x86_64                                                                                                            3/4 
  Verifying  : mysql-community-client-5.7.21-1.el7.x86_64                                                                                                          4/4 

Installed:
  mysql-community-server.x86_64 0:5.7.21-1.el7                                                                                                                         

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.21-1.el7            mysql-community-common.x86_64 0:5.7.21-1.el7            mysql-community-libs.x86_64 0:5.7.21-1.el7           

Complete!

 

五、初始化mysql

使用mysqld --initialize初始化mysql

 --initialize :初始化時,會生成一個root用戶和一個隨機的密碼,並且密碼設置為過期,需要立即修改密碼。確保資料庫目錄與文件的所有者為mysql賬戶,以便在運行mysqld服務時對這些目錄和文件有讀取與寫入許可權。以root身份運行mysqld服務,需指定--user=mysql選項

     註意本例沒有指定user選項,所以後面啟動mysql時出現報錯,需要修改相關文件系統許可權才可以正常啟動,使用下麵的命令初始化會避免這一問題(未驗證,待定)

#mysqld --initialize --user=mysql

--initialize-insecure :另外,可以使用該配置初始化,但這種方式會生成一個root用戶,並且密碼是空(第一次登錄密碼空即可),同樣需要立即修改密碼。可以使用mysql -u root --skip-password直接登錄mysql。

本例採用第一種:

[root@rhel:~]#mysqld --initialize

初始化後,會生成一個root用戶(mysql的用戶,非系統的root用戶)和一個隨機密碼。

[root@rhel:~]#which mysqld
/usr/sbin/mysqld
[root@rhel:~]#grep 'temporary password' /var/log/mysqld.log
2018-03-16T01:10:40.569111Z 1 [Note] A temporary password is generated for root@localhost: _iBhf7suG,go

六、啟動mysql,查看mysql的狀態並設置開機啟動

[root@rhel:~]#systemctl start mysqld 
Redirecting to /bin/systemctl start  mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

無法啟動,需要修改/var/lib/mysql的許可權(由於初始化時沒有指定用戶--user=mysql,未驗證,待定)

[root@rhel:~]#chown mysql:mysql -R /var/lib/mysql

再次啟動,成功

[root@rhel:~]#systemctl start mysqld
Redirecting to /bin/systemctl start  mysqld.service

查看mysql狀態

[root@rhel:~]#systemctl status mysqld
Redirecting to /bin/systemctl status  mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor 
   Active: active (running) since Fri 2018-03-16 09:37:07 CST; 1h 21min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 16216 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run
  Process: 16194 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, sta
 Main PID: 16219 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─16219 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/

Mar 16 09:37:05 rhel systemd[1]: Starting MySQL Server...
Mar 16 09:37:07 rhel systemd[1]: Started MySQL Server.

設置開機啟動

[root@rhel:~]#systemctl enable mysqld

其實質是,增加由/usr/lib/systemd/system/到/etc/systemd/system/multi-user.target.wants/下的軟鏈接

ln -s '/usr/lib/systemd/system/mysqld.service' '/etc/systemd/system/multi-user.target.wants/mysqld.service'   使用命令  #systemctl disable mysqld  可以取消開機自動啟動,實質是刪除/etc/systemd/system/multi-user.target.wants/下的mysqld.service軟連接

七、修改mysql的root密碼

首先,修改mysql的root用戶密碼,因為安全配置嚮導里需要輸入密碼,而隨機生成的密碼比較複雜,所以設置新密碼方便輸入。

共有兩種修改方式:

第一種,使用mysqladmin修改密碼

  1.如果 mysql的root用戶現在沒有密碼,你希望的密碼修改為123456,那麼命令是:

# mysqladmin -u root password 123456 

  2.如果mysql的root現在有密碼(123456),那麼修改密碼為abcdef的命令是:

  # mysqladmin -u root -p password abcdef

註意,命令回車後會提示舊密碼,輸入舊密碼123456之後命令完成,密碼修改成功。

[root@rhel:~]#mysqladmin -u root -p password abcdef
Enter password: 
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

 第二種,若是忘記密碼,可以通過以下方式重置mysql的root用戶密碼

      編輯/etc/my.cnf文件, 在 [mysqld] 中加上一行跳過許可權限制(skip-grant-tables)

root@rhel:~]#vi /etc/my.cnf

[mysqld]

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

skip-grant-tables

      保存退出,重啟mysql服務

[root@rhel:~]#systemctl restart mysqld

     然後登錄,修改密碼欄位,刷新許可權

[root@rhel:~]#mysql -uroot -p
Enter password:                ###密碼為空,直接回車即可
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql                                                                
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
mysql> update user set authentication_string=password('123456') where user='root';      
mysql> flush privileges;

退出,然後編輯/etc/my.cnf文件, 在 [mysqld] 中刪掉一行跳過許可權限制(skip-grant-tables)

root@rhel:~]#vi /etc/my.cnf
[mysqld]

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

skip-grant-tables       #######刪除此行

保存退出,重啟mysql服務

[root@rhel:~]#systemctl restart mysqld

 登錄mysql,若提示需要再次修改密碼,則根據提示修改,若無此提示直接連至資料庫。

[root@rhel:~]#mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

八、MySQL安全配置嚮導mysql_secure_installation

 

[root@rhel:~]#mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 25 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y     ######是否移除匿名用戶
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n     ##############是否禁止mysql的root用戶遠程登錄,測試環境,所以允許

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n ########是否移除test資料庫,測試環境,保留

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y       #######是否重新載入許可權表
Success.

All done! 

 

至此,安裝完成。

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 埠概述 在STM32中,每個I/O埠可以由軟體配置成為輸入/輸出模式。複位期間或剛複位後,I/O埠被配置成浮空輸入模式。所有的GPIO引腳有一個內部弱上拉和弱下拉,當配置為輸入時, 它們可以被激活或者是斷開。 所有的埠都有外部中斷的能力。 AF功能:對於復用功能,埠必須配置成復用功能輸出模 ...
  • 此方法不需要修改Tomcat配置 親測,可用 1.在tomcat bin目錄下添加文件clear_log.sh 內容如下: #!/bin/shd=`date +%Y-%m-%d`d7=`date -d'7 day ago' +%Y-%m-%d`cp /opt/apache-tomcat-8.5.9/ ...
  • 1、列出當前系統上所有已經登錄的用戶的用戶名,註意:同一個用戶登錄多次,則只顯示一次即可。 2、取出最後登錄到當前系統的用戶的相關信息。 3、取出當前系統上被用戶當作其預設shell的最多的那個shell。 4、將/etc/passwd中的第三個欄位數值最大的後10個用戶的信息全部改為大寫後保存至/ ...
  • 1.虛擬機把磁碟大小進行改動 2.sudo apt-get install gparted 3.打開安裝好的應用 4.進行分區改動 5.理論刪除sda2和sda5重整後邊即可,但此時sda2和sda5可能會處在啟用交互的狀態: 6.右鍵禁止後依次刪除sda5和sda2,重新分配sda1後,把預留的位 ...
  • 一、高通sensor架構: linux驅動由淺入深系列:高通sensor架構實例分析之一(整體概覽+AP側代碼分析) linux驅動由淺入深系列:高通sensor架構實例分析之二(adsp驅動代碼結構) Linux驅動由淺入深系列:高通sensor架構實例分析之三(adsp上報數據詳解、校準流程詳解 ...
  • 一、概述 本篇文章轉載來著官網線上文檔,文章主要介紹SQL Server數據類型轉換相關語法、隱式轉換、Date樣式等。 語法 Syntax for CAST: CAST ( expression AS data_type [ ( length ) ] ) Syntax for CONVERT: C ...
  • window eclipse連接hadoop集群,本地運行wordcount,報以下錯誤,嘗試網路上的方法無果,如:換64JDK,添加hadoop_home,path,以及在hadoop\bin和c:\windows\system32下放hadoop.dll。 解決:刪除hadoop\bin\had ...
  • 在MySQL中,它是按什麼順序或規律去讀取my.cnf配置文件的呢?其實只要你花一點功夫,實驗測試一下就能弄清楚,下麵的實驗環境為5.7.21 MySQL Community Server。其它版本如有不同,請以實際情況為準。 其實,MySQL是按照下麵這個順序來讀取my.cnf: 1: /etc/... ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...