[TOC] #### 1. 本地數(shù)據(jù)庫 --- **新建一個 MySQL 連接** ![](https://img.itqaq.com/art/content/104997991895e907bb3c926fce2eb617.png) **直接輸入連接名、MySQL用戶名和密碼就行** ![](https://img.itqaq.com/art/content/fc51c996aaab38839c0d97ce2875059e.png) #### 2. 服務(wù)器端數(shù)據(jù)庫 --- 情景假設(shè):服務(wù)器上安裝寶塔面板,在寶塔面板中創(chuàng)建的 MySQL 數(shù)據(jù)庫 **一. 服務(wù)器運行商安全組放開 3306 端口** ![](https://img.itqaq.com/art/content/7997a74ab86c8d1968fcb8492fe02afc.png) **二. 寶塔面板防火墻放開 3306 端口** ![](https://img.itqaq.com/art/content/e9ce3cf3e07faf2075721a3d21f3498a.png) **三. 放開數(shù)據(jù)庫權(quán)限** ![](https://img.itqaq.com/art/content/aeec8c275450a0ac3b77cf128b59a75a.png) **四. 連接參數(shù)** | 參數(shù)項 | 參數(shù)值 | | ------------ | ------------ | | 主機 | 服務(wù)器公網(wǎng) IP | | 端口 | MySQL 端口 | | 用戶名、密碼 | MySQL 用戶名密碼 | ![](https://img.itqaq.com/art/content/cb1486f762818869a978e4cd52773516.png) #### 3. 云服務(wù)器數(shù)據(jù)庫(騰訊云) --- 微擎 config.php | 參數(shù)項 | 參數(shù)值 | | ------------ | ------------ | | host | gz-cdb-9v361hm1.sql.tencentcdb.com:62104 | | username | wx_dianduxxx | | password | qq7801xxx | | port | 3306 | **一、ping 云數(shù)據(jù)庫服務(wù)器域名,獲得服務(wù)器 IP** ![](https://img.itqaq.com/art/content/91e0587815663cbc3cd9b7b47e1b89d0.png) **二、創(chuàng)建騰訊云云數(shù)據(jù)庫連接** ![](https://img.itqaq.com/art/content/430a8b4a39644aecfee2696c6e12a663.png) **三、輸入連接參數(shù),測試連接** ![](https://img.itqaq.com/art/content/2a2cf4d6ec5137b3bc4d6d222b28a30c.png)