2010-12-09 162 views
22

我無法讓PHPMyAdmin連接到我的Amazon RDS實例。我已授予我的IP地址權限給數據庫安全組,可以訪問我嘗試訪問的此數據庫。這裏就是我的工作......使用PHPMyAdmin管理Amazon RDS

$cfg['Servers'][$i]['pmadb'] = $dbname; 
    $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark'; 
    $cfg['Servers'][$i]['relation'] = 'pma_relation'; 
    $cfg['Servers'][$i]['table_info'] = 'pma_table_info'; 
    $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords'; 
    $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages'; 
    $cfg['Servers'][$i]['column_info'] = 'pma_column_info'; 
    $cfg['Servers'][$i]['history'] = 'pma_history'; 
    $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords'; 

    /* Uncomment the following to enable logging in to passwordless accounts, 
    * after taking note of the associated security risks. */ 
    // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; 

    /* Advance to next server for rest of config */ 
    $i++; 
} 

    $cfg['Servers'][$i]['auth_type'] = 'http'; //is this correct? 
    $cfg['Servers'][$i]['user'] = 'MASTER-USER'; 
    $cfg['Servers'][$i]['password'] = 'MASTER-USER-PASSWORD'; 
    $cfg['Servers'][$i]['hide_db'] = '(mysql|information_schema|phpmyadmin)'; 
    /* Server parameters */ 
    $cfg['Servers'][$i]['host'] = 'MY-DB.us-east-1.rds.amazonaws.com'; 
    $cfg['Servers'][$i]['connection_type'] = 'socket'; 
    $cfg['Servers'][$i]['port'] = PORT; 

我不知道如果我的配置是正確的......

我得到這個錯誤:#2013 - Lost connection to MySQL server at 'reading initial communication packet', system error: 110

任何人有任何建議?

回答

16

我發現大部分的答案在這個問題缺乏解釋。要在安裝在EC2中的phpMyAdmin中添加RDS服務器,您可以先通過SSH登錄到您的EC2。然後,發出以下命令編輯phpMyAdmin的(使用vinano或其他任何喜歡的文本編輯工具)的配置文件:

sudo vi /etc/phpMyAdmin/config.inc.php # Amazon Linux 
sudo vi /etc/phpmyadmin/config.inc.php # Ubuntu Linux 

找到以下行config.inc.php

/* 
* End of servers configuration 
*/ 

追加以下行以上「服務器端配置」行:

$i++; 
$cfg['Servers'][$i]['host'] = 'xxxxx.xxxxxxxxxx.us-east-1.rds.amazonaws.com'; 
$cfg['Servers'][$i]['port'] = '3306'; 
$cfg['Servers'][$i]['verbose'] = 'YOUR_SERVER_NAME'; 
$cfg['Servers'][$i]['connect_type'] = 'tcp'; 
$cfg['Servers'][$i]['extension'] = 'mysql'; 
$cfg['Servers'][$i]['compress'] = TRUE; 

其中YOUR_SERVER_NAME是在phpMyAdmin登錄頁面的選擇框中顯示的名稱。如果刪除這一行,則整個RDS主機名將顯示在選擇框中(顯然這太長)。請記住保存config.inc.php

還有其他幾個配置設置,您可以在official documentation中找到詳細信息。


注:對方回答提示自動登錄預設的用戶名密碼&在配置文件中:

$cfg['Servers'][$i]['auth_type']  = 'config'; 
$cfg['Servers'][$i]['user']   = '__FILL_IN_DETAILS__'; 
$cfg['Servers'][$i]['password']  = '__FILL_IN_DETAILS__'; 

這是極其危險如果你的phpMyAdmin是向公衆公開。你不想把你的數據庫模式顯示給每個人,是嗎?如果你真的想使用自動登錄,請確保你的phpMyAdmin只能通過特定的IP訪問。

13

您需要添加RDS實例作爲PHPMyAdmin上列出的其他服務器,同時授予對您的RDS實例的主機PHPMyAdmin訪問權限。

從這個博客帖子更多細節上How to remotely manage an Amazon RDS instance with PHPMyAdmin

The one thing I had trouble with was the DB Security Group setup. When you go to add access for an CIDR/IP it provides a recommended value. It took some messing around to determine that this default value isn’t actually what needed to be there. If you’re not able to connect to your instance when it’s all said and done, be sure to double check this value. The IP they provided did not match the IP address that was provided to us by our ISP. Once you’ve created your DB Instance and setup the security group you’re good to go.

I’m going to assume you’ve already got PHPMyAdmin up and running. What you need to do is modify config.inc.php to recognize the new server.

+15

請不要只發布鏈接作爲答案。將答案發布爲文本,如果需要,請提供鏈接以供進一步解釋。這樣,如果鏈路死亡,答案仍然存在。 – 2010-12-10 15:26:07

+2

我調整了我的文章 – Webnet 2010-12-10 16:45:37

+0

如果您的RDS位於VPC 關於安全組,AWS有一個關於在VPC內從EC2連接到RDS的教程: http://docs.aws.amazon.com /AmazonRDS/latest/UserGuide/USER_VPC.Scenarios.html 尤其需要編輯VPC安全組入站規則,以添加您的EC2實例所在的安全組的ID(或者如果不使用EC2,則使用IP2服務器要訪問RDS) – Baxny 2016-07-14 13:17:21

8

嘗試從mysql命令行(http://dev.mysql.com/doc/refman/5.1/en/mysql.html連接),看看這個工具返回你的東西。我發現這樣調試更容易。

mysql -hMY-DB.us-east-1.rds.amazonaws.com -uMASTER-USER -pPASSWORD 

如果這不起作用,這意味着您的amazon RDS安全配置不正確。 (這是常見的問題)。使用來自回購phpMyAdmin的

21

在Debian的萊尼添加這/etc/phpmyadmin/config.inc.php :

$i++; 
$cfg['Servers'][$i]['host'] = 'xxxxx.xxxxxxxxxx.us-east-1.rds.amazonaws.com'; 
$cfg['Servers'][$i]['port'] = '3306'; 
$cfg['Servers'][$i]['socket'] = ''; 
$cfg['Servers'][$i]['connect_type'] = 'tcp'; 
$cfg['Servers'][$i]['extension'] = 'mysql'; 
$cfg['Servers'][$i]['compress'] = TRUE; 
$cfg['Servers'][$i]['auth_type'] = 'config'; 
$cfg['Servers'][$i]['user'] = 'xxxxxxxxxxxx'; 
$cfg['Servers'][$i]['password'] = 'xxxxxxxxxxxxxxxxxx'; 
0

我有同樣的問題,並沒有上述解決它。

事實證明,事情發生在RDS實例的「公開訪問」選項中。在創建實例時,默認情況下該選項爲「否」,並且沒有地方可以更改它。

但是,在創建RDS實例後,您可以創建快照,然後刪除實例並啓動快照。在啓動選項中,只需將「公開訪問」設置爲「是」,您的phpMyAdmin就會最終看到您的RDS MySql服務器。

謹防原RDS實例和snaphot的是DNS是不同的,所以你必須改變你的「主」在config.inc.php中

乾杯:)

-1

我使用Ubuntu shell來訪問亞馬遜RDS。 首先是去ubuntu的根

sudo -i 

做到這一點使用Amazon RDS終端用戶URL

mysql -h gelastik.cqtbtepzqfhu.us-west-2.rds.amazonaws.com -u root -p 
4
sudo nano /etc/phpmyadmin/config.inc.php 

--ADD LINES BELOW THE PMA CONFIG AREA AND FILL IN DETAILS-- 
$i++; 
$cfg['Servers'][$i]['host']   = '__FILL_IN_DETAILS__'; 
$cfg['Servers'][$i]['port']   = '3306'; 
$cfg['Servers'][$i]['socket']  = ''; 
$cfg['Servers'][$i]['connect_type'] = 'tcp'; 
$cfg['Servers'][$i]['extension']  = 'mysql'; 
$cfg['Servers'][$i]['compress']  = FALSE; 
$cfg['Servers'][$i]['auth_type']  = 'config'; 
$cfg['Servers'][$i]['user']   = '__FILL_IN_DETAILS__'; 
$cfg['Servers'][$i]['password']  = '__FILL_IN_DETAILS__'; 

保存並退出。刷新您的phpMyAdmin的網頁,你會看到剛纔添加enter image description here

源的服務器下拉:https://github.com/andrewpuch/phpmyadmin_connect_to_rdshttps://www.youtube.com/watch?v=Bz-4wTGD2_Q

0

第一次嘗試這樣的:

的mysql -h xxxxx.xxxxxxx.xx-xx-2.rds.amazonaws.comü根 - P //你的RDS服務器。

如果它等待並且沒有提示輸入密碼,那麼您需要檢查安全組並將3306出站內容添加到Web層。