1. 程式人生 > >阿裏雲服務器 ——寶塔面板配置安裝的數據庫如何進行遠程連接

阿裏雲服務器 ——寶塔面板配置安裝的數據庫如何進行遠程連接

mman nds 一個用戶 reg oracl 添加 affect clear ***

首先在服務器安全組添加3306放行端口

繼而再去面板中添加3306放行端口

在阿裏雲服務器中登錄mysql進行遠程配置(權限為root才能配置,否則配置不成功)

1. 先用localhost登錄
# mysql -u root -p
Enter password:
2. 執行授權命令
mysql> grant all privileges on *.* to root@‘%‘ identified by ‘password‘; 紅色底板的password自行設置
Query OK, 0 rows affected (0.07 sec)
3. 退出再試
mysql> quit
Bye
再試登錄:(這裏測試用另一臺主機(我這裏用win10的cmd命令行連接)就能登錄,得先連網)

C:\Users\ASDS>mysql -uroot -h 主機ip -p 紅色底板的主機ip是要連接的數據庫的載體主機ip
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.5.61-log Source distribution

Copyright (c) 2000, 2017, 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> create user geek identified by ‘password‘;
Query OK, 0 rows affected (0.00 sec)

執行授權連接單獨的一個數據庫,我這裏連接test數據庫:

mysql> grant all privileges on test.* to geek@‘%‘;
Query OK, 0 rows affected (0.00 sec)

登錄測試

C:\Users\ASDS>mysql -ugeek -h 128.10.2.64 -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.5.61-log Source distribution

Copyright (c) 2000, 2017, 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>

登錄成功

阿裏雲服務器 ——寶塔面板配置安裝的數據庫如何進行遠程連接