
鏡像下載下傳、域名解析、時間同步請點選
阿裡巴巴開源鏡像站一、前提條件
- 已注冊阿裡雲賬号。
- 如果在中國内地地域中使用雲伺服器ECS,請確定賬号已完成實名認證。
- 已建立一台ECS執行個體。詳細步驟請參見 使用向導建立執行個體 。
二、背景資訊
本教程在示例步驟中使用了以下執行個體規格和版本軟體。實際操作時,請以您的軟體版本為準。
- 執行個體規格:ecs.c6.large(2 vCPU,4 GiB記憶體)
- 作業系統:公共鏡像CentOS 7.2 64位
- MySQL:5.7.26
- 資料庫端口:3306
說明 您需要在ECS執行個體所使用的安全組入方向添加規則并放行3306端口。具體步驟,請參見 添加安全組規則
三、操作步驟
步驟一:準備環境
遠端連接配接您的ECS執行個體。具體操作,請參見
使用SSH密鑰對連接配接Linux執行個體或
使用使用者名密碼驗證連接配接Linux執行個體步驟二:安裝MySQL
1、運作以下指令更新YUM源。(點選
試用)
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2、運作以下指令安裝MySQL。
yum -y install mysql-community-server
3、運作以下指令檢視MySQL版本号。
mysql -V
傳回結果如下,表示MySQL安裝成功。
mysql Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using EditLine wrapper
步驟三:配置MySQL
1、運作以下指令啟動MySQL服務。
systemctl start mysqld
2、運作以下指令設定MySQL服務開機自啟動。
systemctl enable mysqld
3、運作以下指令檢視/var/log/mysqld.log檔案,擷取并記錄root使用者的初始密碼。
# grep 'temporary password' /var/log/mysqld.log
2019-04-28T06:50:56.674085Z 1 [Note] A temporary password is generated for root@localhost: 3w)WqGlM7-o,
說明 下一步對MySQL進行安全性配置時,會使用該初始密碼。
4、運作下列指令對MySQL進行安全性配置。
mysql_secure_installation
- 重置root使用者的密碼。
Enter password for user root: #輸入上一步擷取的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: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y #是否更改root使用者密碼,輸入Y
New password: #輸入新密碼,長度為8至30個字元,必須同時包含大小寫英文字母、數字和特殊符号。特殊符号可以是()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/
Re-enter new password: #再次輸入新密碼
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y #是否繼續操作,輸入Y
- 删除匿名使用者賬号。
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 #是否删除匿名使用者,輸入Y
Success.
- 禁止root賬号遠端登入。
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root遠端登入,輸入Y
Success.
- 删除test庫以及對test庫的通路權限。
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否删除test庫和對它的通路權限,輸入Y
- Dropping test database...
Success.
- 重新加載授權表。
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #是否重新加載授權表,輸入Y
Success.
All done!
安全性配置的更多詳情,請參見
MySQL官方文檔步驟四:遠端通路MySQL資料庫
您可以使用資料庫用戶端或阿裡雲提供的資料管理服務DMS(Data Management Service)來遠端通路MySQL資料庫。本節以DMS為例,介紹遠端通路MySQL資料庫的操作步驟。
1、在ECS執行個體上,建立遠端登入MySQL的賬号。
- 運作以下指令後,輸入root使用者的密碼登入MySQL。
mysql -uroot -p
- 依次運作以下指令建立遠端登入MySQL的賬号。示例賬号為
、密碼為dms
123456
mysql> grant all on *.* to 'dms'@'%'IDENTIFIED BY '123456'; #使用root替換dms,可設定為允許root賬号遠端登入。
mysql> flush privileges;
說明
- 建議您使用非root賬号遠端登入MySQL資料庫。
- 實際建立賬号時,需将
更換為符合要求的密碼: 長度為8至30個字元,必須同時包含大小寫英文字母、數字和特殊符号。特殊符号可以是
123456
~!@#$%^&*-+=|{}[]:;‘<>,.?/`。
()
- 登入 資料管理控制台
- 在左側導航欄中,選擇自建庫(ECS、公網)。
- 單擊新增資料庫。
- 配置自建資料庫資訊。 配置詳情,請參見 管理ECS執行個體自建資料庫
- 單擊登入。成功登入後,您可以使用DMS提供的菜單欄功能,建立資料庫、表、函數等。
“ 提供全面,高效和穩定的鏡像下載下傳服務。釘釘搜尋 ' 21746399 ‘ 加入鏡像站官方使用者交流群。”